Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6471077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:11:00+00:00 2026-05-25T06:11:00+00:00

Defining my boost::graph like the following, I get edge indices zero for all edges.

  • 0

Defining my boost::graph like the following, I get edge indices zero for all edges. Why? What am I doing wrong?

#include <iostream>
#include <boost/graph/adjacency_list.hpp>

int main() {
    typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, boost::no_property, boost::property<boost::edge_index_t, std::size_t> > Graph;
    typedef boost::graph_traits<Graph>::edge_descriptor Edge;

    Graph g(3);
    Edge e1 = boost::add_edge(0, 1, g).first;
    Edge e2 = boost::add_edge(1, 2, g).first;
    Edge e3 = boost::add_edge(2, 0, g).first;

    boost::property_map<Graph, boost::edge_index_t>::type eim = boost::get(boost::edge_index, g);
    size_t e1n = eim[e1],
           e2n = eim[e2],
           e3n = eim[e3];

    return 0;
}

As far as I can tell from documentation and examples, this should work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:11:01+00:00Added an answer on May 25, 2026 at 6:11 am

    An adjacency_list doesn’t have an edge index associated with it, only a vertex index. Which is quite logical once you think about how the graph is stored.

    To have an edge index, you need to manually add it to the graph description, and then manually handle it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm defining an unordered_map in C++ like the following: unordered_map<CustomClass, int, CustomClassHash, CustomClassEq> myMap;
What harm can come from defining BOOST_DISABLE_ABI_HEADERS when compiling boost? From the boost file:
When defining a method on a class in Python, it looks something like this:
I'm defining a datagrid's RowDetailsTemplate in the following way: RowDetailsTemplate={StaticResource defaultTemplate} where <UserControl.Resources> <DataTemplate
I'm trying to create a threadpool with the boost threadpool library, but on defining
I am trying to build some big libraries, like Boost and OpenCV , from
While defining the following lambda function // file prog.hpp template<typename T> auto function =
I find myself defining classes like: struct AngleSize { explicit AngleSize(double radians) : size(radians)
When defining a JavaScript call, like so: <input type=button onclick=someJavaScriptFunction /> What is the
Is there a way to use boost foreach without defining a const_iterator ? My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.