I am having trouble visualizing a multidirectional graph with parallel edges in networkx so I have resorted to using pydot, but I am having two issues
1) I cant seem to understand why the node positions are not being fixed I would like to plot them at the x and y specified coordinates 2) How do I set the size of the figure being plotted the plt.figure command does not really work 3) How do I add edge labels (if I had them)
many thanks
import networkx as nx
from io import StringIO
from io import BytesIO
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import networkx as nx
graph= nx.MultiGraph()
#add 4 nodes in the vertexs of a square. X and Y are the coordinates
graph.add_node(1,x=100,y=100)
graph.add_node(2,x=100,y=200)
graph.add_node(3,x=200,y=100)
graph.add_node(4,x=200,y=200)
graph.add_edge(1,2)
graph.add_edge(2,1)
graph.add_edge(3,1)
graph.add_edge(3,4)
graph.add_edge(4,1)
# assign positions
for n in graph:
graph.node[n]['pos'] = '"%d,%d"'%(graph.node[n]['x'], graph.node[n]['y'])
p = nx.drawing.nx_pydot.to_pydot(graph)
# render pydot by calling dot, no file saved to disk
png_str = p.create_png(prog='C:\\Anaconda3\\Library\\bin\\graphviz\\dot.exe')
# treat the dot output string as an image file
sio = BytesIO()
sio.write(png_str)
sio.seek(0)
img = mpimg.imread(sio)
plt.figure(figsize = (10,10))
imgplot = plt.imshow(img)