In [1]:
from py2cytoscape.data.cyrest_client import CyRestClient
cy = CyRestClient(ip='127.0.0.1', port=1234)
# 現在のセッションのクリア
cy.session.delete()
In [2]:
import networkx as nx
g = nx.scale_free_graph(500)
In [3]:
deg = nx.degree(g)
btw = nx.betweenness_centrality(g)
nx.set_node_attributes(g, 'degree', deg)
nx.set_node_attributes(g, 'betweenness', btw)
In [4]:
g_cy = cy.network.create_from_networkx(g)
In [5]:
cy.layout.apply(name='kamada-kawai', network=g_cy)
In [6]:
directed = cy.style.create('Directed')
cy.style.apply(directed, network=g_cy)
In [11]:
cy.edgebundling.apply(g_cy)
In [7]:
image = g_cy.get_png()
from IPython.display import Image
Image(image)
In [13]:
image_svg = g_cy.get_svg()
from IPython.display import SVG
SVG(image_svg)
Out[13]:
In [10]:
image_pdf = g_cy.get_pdf()
print(type(image_pdf))
f = open('network1.pdf', 'wb')
f.write(image_pdf)
f.close()