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.

Revisions

  1. hideaki-t revised this gist Jan 15, 2012. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    # coding: utf-8
    import networkx
    G=networkx.Graph()
  2. hideaki-t created this gist Jan 15, 2012.
    27 changes: 27 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@

    # 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()