0

I have a ListDigraph and related node and arc maps, namely,

ListDigraph::ArcMap<int>length;
ListDigraph::NodeMap<int> label;

I have a list of nodes, belonging to the graph. I would like to build a subgraph which has list of nodes mentioned before.

I'm using the LEMON library, but I cannot find a nice solution for it.

I used the reference here: http://lemon.cs.elte.hu/pub/tutorial/a00009.html but actually this does not help, for Digraphs it does not accept both arc and node maps in the copy of the graph.

Is there a simple solution that given a list of node I want to maintain, I can obtain the subgraph with only those nodes together with the arcs connected to them (unless the other end of the arc belonged to a now-erased node) ? Of course, also the edge map should be preserve: the label (length) on the arcs must remain.

  • "giving for each node a list of nodes that maintain a given property." ??? Maybe you mean "for each property a list of nodes that maintain that property" Or maybe " for each node a list of nodes that maintain the same property." – ravenspoint Jun 29 '23 at 14:02
  • no, I meant what I said: I have the nodes. then I have a map that has the node_id as key and a vector of node_ids as value. The node_ids in the vectors respect a property regarding the key node_id. In this specific example, are all the nodes in a given radious from a given source – Claudio Tomasi Jun 29 '23 at 14:04
  • "respect a property" What does it mean to respect a property? – ravenspoint Jun 29 '23 at 14:05
  • It is not so important, I'll edit the question, we're going out of focus here – Claudio Tomasi Jun 29 '23 at 14:06
  • It is very important to be clear. Fuzzy writing leads to fuzzy thinking and answers that are confused or wrong – ravenspoint Jun 29 '23 at 14:07
  • That is better, but still confusing. I think you mean "a subgraph of the input graph that contains only a given subset of the nodes in the input graph" – ravenspoint Jun 29 '23 at 14:10
  • yep, exactly. I just want to build a subgraph given a set of nodes I want to maintain. But I want to avoid to build this graph from beginning – Claudio Tomasi Jun 29 '23 at 14:11

1 Answers1

0
  • Copy the input graph, call it g2
  • LOOP N over nodes in g2
    • If N NOT in nodes subset to be maintained
      • REMOVE from g2 all edges connected to N
      • REMOVE N from g2
  • RETURN g2
ravenspoint
  • 19,093
  • 6
  • 57
  • 103