Julia / Graphs.jl : creating graph using graph() and arguments

Viewed 380

I am trying to get subgraph from graph in Julia using Graphs.jl module. I have graph and i store his vertices and edges to list and then my algorithm moves trough this list and remove nodes and edges which are not part of new subgraph. To this part everything works correctly, after whole algorithm all that remains is array sub_vertices type: Graphs.ExVertex[] and array sub_edges type: Graphs.ExEdge{Graphs.ExVertex}[].

At the end of whole function I wanto to create subgraph so I use:

sub_g = graph(sub_vertices, sub_edges, is_directed=false)

But i get Bounds() error. Any idea ? All I know that problem is in edges.

I tried to run:

sub_g = graph(sub_vertices, Graphs.ExEdge{Graphs.ExVertex}[], is_directed=false)

And it runs ok. It creates graph with vertices given by array sub_vertices. Problem occurs when adding edges with sub_edges.

Additional info: Vertices and Edges are exact copies from original graph. That means attributes like index, label, ... are same as in original graph. I thought that maybe indexes of vertices will be problem but It is not because when i run,

sub_g = graph(sub_vertices, Graphs.ExEdge{Graphs.ExVertex}[], is_directed=false)

it runs OK. And after printing the vertices they have indexes for example 1,3,5 but it seems ok. So i do not know why edges gives bounds error.

1 Answers
Related