繁体   English   中英

从Pydot图返回NetworkX图

[英]Returns a NetworkX graph from a Pydot graph

[当我尝试安装pygraphviz时,该图像显示错误] [1]我使用PLG2软件创建了一个网络,并将其保存为.dot格式,如何从此模式切换到networkx图形?

from networkx.drawing import nx_agraph
from node2vec import Node2Vec
dotFormat= pydot.graph_from_dot_file(r'path')
def read_dot(dotFormat):
    try:
        import pygraphviz
    except ImportError:
        raise ImportError('read_dot() requires pygraphviz ',
                          'http://pygraphviz.github.io/')
    A=pygraphviz.AGraph(file=dotFormat)
    G = nx_agraph.from_agraph(pygraphviz.AGraph(dotFormat))  ```


  [1]: https://i.stack.imgur.com/LuI65.png
This is the error when I try to install pygraphviz on Pycharm on Windows10 with Python 3.6
'''    Command "C:\Users\Admin1\AppData\Local\Programs\Python\Python37-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Admin1\\AppData\\Local\\Temp\\pycharm-packaging\\pygraphviz\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Admin1\AppData\Local\Temp\pip-record-59rpzl5r\install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in C:\Users\Admin1\AppData\Local\Temp\pycharm-packaging\pygraphviz\
You are using pip version 10.0.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command   '''.

from_pydot的方法networkx可能是准确的,你需要的方法。

如文档中所述,您应该知道,它将返回一个MultiGraph。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM