BGL: How to efficiently store edge_descriptors and vertex_descriptors?

So, after my circular dependency problem with BGL was resolved, I came up with another hurdle.

I am currently using the adjacency list to simulate my graph. Bound properties for nodes and edges are used to store some information on the graph. So I have something like this:

class Node {
    int x, int y // position
};
class Edge {
    float length;
};

boost::adjacency_list<boost::listS, boost::listS, boost::directedS, Node, Edge>

The problem arises when I want to store shortcuts for certain nodes and edges somewhere else in my code (for example, for a street that has several lanes). My first approach was to keep edge_descriptors and vertex_descriptors where I need them. But I wonder how big (in terms of bytes) such descriptors are. Maybe there is a better solution, for example, to store only a small part of the information in order to get the same results.

Does anyone know the amount of memory that is used for a vector of this type:

std::vector<edge_descriptor> ?

I already thought about just saving pointers to edge_descriptors, but I don’t know if this will work and how.

//////////////////////////////////////////////////// //////////////////////////////////////////////////// //////////////////////////////////////////////////// ///////////////

EDIT: , , . - . , . , . :

  • hash_map std::tr1::unordered_map<int, edge_descriptor>, , -. - , . .
  • . , . node, - :
    boost::property_map<My_Graph, my_prop>::type index = get(my_prop(), G);

?

, ?

+2
1

.

- . Edge , , , .

, . .

+1

Source: https://habr.com/ru/post/1775965/


All Articles