Calculate number of in and out edges in a boost::graph vertex

2.8k Views Asked by At

I've the following graph type

typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, PathVertex, PathEdge> GraphStructure;

I insert some directed edges.

Now, for every vertex, I want to calculate number of in edges and out edges.

For now, I've discovered the m_out_edges structure

GraphStructure xGraph;

add_edge(0, 1, xGraph);
add_edge(1, 2, xGraph);
add_edge(2, 1, xGraph);

int iValue = xGraph.m_vertices.at(0).m_out_edges.size();

But I don't know if it's what I want, and there's always the problem of in edges that I can't calculate at the moment.

So, given an adjacency_list, how can I iterate through its vertices, and know how many are input edges and output edges, separately?

Thanks in advance for your replies.

0

There are 0 best solutions below