Search code examples
rgraphextractvertexsubgraph

finding all paths in a graph including a vertex


I have a directed simple graph (named tutti) and a list of vertex (named risultato).

I want to find the full set of subgraph extracted by "tutti" that includes a vertex in the array risultato.

As example in the included picture the graph tutti

enter image description here

Given the vertex 609 (that is one vertex present in risultato) (in red on the left) i need to plot the graph in picture

enter image description here How can i extract all those graphs?


Solution

  • The vertexes to be taken in consideration are in the array risultato.

    return all path in "tutti" graph arriving to each element in risultato:

    sottografierrorisopra<-graph.neighborhood (tutti,vcount(tutti),risultato, "in")

    return all path in "tutti" graph starting from the vertex in the risultato #array

    sottografierrorisotto<-graph.neighborhood (tutti,vcount(tutti),risultato, "out")

    union of the graphs

    zz<- graph.union (sottografierrorisopra, sottografierrorisotto)