Graphviz segmentation error

I am building a graph with many nodes, about 3000. I wrote a simple python program to do the trick using Graphviz, but it gives me a segmentation error, and I don’t know why if the graph is too big or if I missed something.

The code:

#!/usr/bin/env python

# Import graphviz
import sys
sys.path.append('..')
sys.path.append('/usr/lib/graphviz')
import gv

# Import pygraph
from pygraph.classes.graph import graph
from pygraph.classes.digraph import digraph
from pygraph.algorithms.searching import breadth_first_search
from pygraph.readwrite.dot import write

# Graph creation
gr = graph()

file = open('nodes.dat', 'r')
line = file.readline()
while line:
        gr.add_nodes([line[0:-1]])
        line = file.readline()

file.close()
print 'nodes finished, beginning edges'

edges = open('edges_ok.dat', 'r')
edge = edges.readline()
while edge:
        gr.add_edge((edge.split()[0], edge.split()[1]))
        edge = edges.readline()

edges.close()
print 'edges finished'
print 'Drawing'

# Draw as PNG
dot = write(gr)
gvv = gv.readstring(dot)
gv.layout(gvv,'dot')
gv.render(gvv,'svg','graph.svg')

and it causes a crash when called gv.layout().

Files are similar to: nodes:

   node1
   node2
   node3

edges_ok:

   node1 node2
   node2 node3
+5
source share
1 answer

I changed the layout type from dot to neato and this solved the problem.

I was looking a bit, and it seems that the layout of the point is a bit wrong on large graphs.

+6
source

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


All Articles