networkx_plot() di Sage

Dodecahedral :

sage: import networkx
sage: D = networkx.dodecahedral_graph()
sage: networkx_plot(D, pos=None, vertex_labels=True, vertex_size=200, vertex_colors=None, edge_colors=None, graph_border=False, scaling_term=0.01, draw_edges=True)

Icosahedral :

sage: import networkx
sage: D = networkx.icosahedral_graph()
sage: networkx_plot(D, pos=None, vertex_labels=True, vertex_size=200, vertex_colors=None, edge_colors=None, graph_border=False, scaling_term=0.05, draw_edges=True)

Tetrahedral :

sage: import networkx
sage: D = networkx.tetrahedral_graph()
sage: networkx_plot(D, pos=None, vertex_labels=True, vertex_size=200, vertex_colors=None, edge_colors=None, graph_border=False, scaling_term=0.05, draw_edges=True)

Octahedral :

sage: import networkx
sage: D = networkx.octahedral_graph()
sage: networkx_plot(D, pos=None, vertex_labels=True, vertex_size=200, vertex_colors=None, edge_colors=None, graph_border=False, scaling_term=0.05, draw_edges=True)

Rainbow Cube :

C = graphs.CubeGraph(7)
from sage.plot.plot import rainbow
R = rainbow(5)
edge_colors = {}
for i in range(5):
….edge_colors[R[i]] = []
for u,v,l in C.edges():
….for i in range(5):
……..if u[i] != v[i]:
………..edge_colors[R[i]].append((u,v,l))
networkx_plot(C.networkx_graph(), pos=C.get_pos(), edge_colors=edge_colors, vertex_labels=False, vertex_size=0)

Petersen Graph :

import networkx
from math import sin, cos, pi
P = networkx.petersen_graph()
d = {‘#FF0000’:[0,5], ‘#FF9900’:[1,6], ‘#FFFF00’:[2,7], ‘#00FF00’:[3,8], ‘#0000FF’:[4,9]}
pos_dict = {}
for i in range(5):
….x = float(cos(pi/2 + ((2*pi)/5)*i))
….y = float(sin(pi/2 + ((2*pi)/5)*i))
….pos_dict[i] = [x,y]

for i in range(10)[5:]:
….x = float(0.5*cos(pi/2 + ((2*pi)/5)*i))
….y = float(0.5*sin(pi/2 + ((2*pi)/5)*i))
….pos_dict[i] = [x,y]

networkx_plot(graph=P, vertex_colors=d, pos=pos_dict)

Catatan :
…… (hapus saja)

[SAGE], SAGE Mathematical Software, Version 3.2.3, http://www.sagemath.org/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s