I've a hard time to figure out how to insert an element in this following type of map. Given:
std::map<Node*, std::vector<pair<Edge*, Node*> > > adjacencyMap;
,where Node
and Edge
are structs. I want to create a graph and each connection between two nodes should be stored in this map. Each node could have more than one connection to another node. The main idea is that for each node there could be a list of pairs of edges and nodes, e.g.
node1 and node2 are connected through an edge12
node1 and node3 are connected through an edge13
The adjacencyMap
should like
node1 -> [(edge12, node2), (edge13, node3)]
node2 -> [(edge12, node1)]
node3 -> [(edge13, node1)]
I know how to insert an element like (node1, pair(edge12,node2))
but I don't know how to insert, if (node1, pair(edge12,node2))
is already an element, (node1, pair(edge13, node3))
sucht that
node1 -> [(edge12, node2), (edge13, node3)].
How can I realize my intention?
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire