Skip to content

Instantly share code, notes, and snippets.

@hideaki-t
Created January 15, 2012 05:39
Show Gist options
  • Save hideaki-t/1614517 to your computer and use it in GitHub Desktop.
Save hideaki-t/1614517 to your computer and use it in GitHub Desktop.
testing japanese text in networkx
# coding: utf-8
import networkx
G=networkx.Graph()
from matplotlib import pyplot
G.add_edge(u'池袋', u'新宿')
G.add_edge(u'新宿', u'代々木')
G.add_edge(u'代々木', u'品川')
G.add_edge(u'品川', u'東京')
G.add_edge(u'東京', u'神田')
G.add_edge(u'神田', u'秋葉原')
G.add_edge(u'秋葉原', u'日暮里')
G.add_edge(u'日暮里', u'田端')
G.add_edge(u'田端', u'池袋')
G.add_edge(u'池袋', u'赤羽')
G.add_edge(u'代々木', u'御茶ノ水')
G.add_edge(u'東京', u'御茶ノ水')
G.add_edge(u'秋葉原', u'御茶ノ水')
G.add_edge(u'日暮里', u'赤羽')
G.add_edge(u'田端', u'赤羽')
pos = networkx.spring_layout(G)
networkx.draw_networkx_nodes(G, pos, node_size=100, node_color='w')
networkx.draw_networkx_edges(G, pos, width=1)
networkx.draw_networkx_labels(G, pos, font_size=12, font_family='VL Gothic', font_color='r')
pyplot.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment