def to_graphml(graph, file):
"""Writes this graph to GraphML XML file using :func:`networkx.write_graphml`. The .graphml file extension is
suggested so Cytoscape can recognize it.
:param BELGraph graph: A BEL graph
:param file file: A file or file-like object
"""
g = nx.MultiDiGraph()
for node, data in graph.nodes(data=True):
g.add_node(node, json=json.dumps(data))
for u, v, key, data in graph.edges(data=True, keys=True):
g.add_edge(u, v, key=key, attr_dict=flatten_dict(data))
nx.write_graphml(g, file)
评论列表
文章目录