0

I’m having a bidirectional graph (i.e. a directed graph in which it is possible to iterate both the in-edges and the out-edges).

Each vertex, among other internal properties, has a special ID property which is an integer from a finite set (couple of hundreds) which is known at program's startup, that is – it won’t change during program's life time, but it is unknown at compile time.

This property is not unique at the scope of the graph (i.e. there can be two Vertices with the same ID), and therefore cannot be used with named/labeled_graph. It is however unique in the scope of a given Vertex, that is both the incoming neighbors and the outgoing neighbors of a vertex should all have different IDs.

My question is whether there is a build in mechanism in BGL to efficiently find an adjacent vertex u, of v given u’s descriptor, the graph, and the ID of u.

This can of course be achieve using some external mapping, but it feels like quite a common scenario, and given that the adjacency_list’s first template parameter can be an associative container – it seems only natural to have some kind of find_adjacent(v,g,ID) function, alas, I wasn’t able to find anything like it.

Many thanks, Andrey

Andrey
  • 23
  • 2

1 Answers1

0

You don't post a sample, but from the description given you could select an ordered set for the OutEdgeList and order it by the target vertex ID (which is unique in that scope).

Now you can use std::lower_bound/std::upper_bound/std::equal_range on the out_edges of any given node.

If you prefer you can easily add free functions like find_adjacent to hide the implementation.

sehe
  • 374,641
  • 47
  • 450
  • 633