本文整理汇总了Python中networkx.draw_spectral函数的典型用法代码示例。如果您正苦于以下问题:Python draw_spectral函数的具体用法?Python draw_spectral怎么用?Python draw_spectral使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draw_spectral函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: draw_graph
def draw_graph(g, out_filename):
nx.draw(g)
nx.draw_random(g)
nx.draw_circular(g)
nx.draw_spectral(g)
plt.savefig(out_filename)
开发者ID:lgadawski,项目名称:tass,代码行数:7,代码来源:tass.py
示例2: ministro_ministro
def ministro_ministro(G):
"""
Cria um grafo de ministros conectados de acordo com a sobreposição de seu uso da legislação
Construido a partir to grafo ministro_lei
"""
GM = nx.Graph()
for m in G:
try:
int(m)
except ValueError:# Add only if node is a minister
if m != "None":
GM.add_node(m.decode('utf-8'))
# Add edges
for n in GM:
for m in GM:
if n == m: continue
if GM.has_edge(n,m) or GM.has_edge(m,n): continue
# Edge weight is the cardinality of the intersection each node neighbor set.
w = len(set(nx.neighbors(G,n.encode('utf-8'))) & set(nx.neighbors(G,m.encode('utf-8')))) #encode again to allow for matches
if w > 5:
GM.add_edge(n,m,{'weight':w})
# abreviate node names
GMA = nx.Graph()
GMA.add_weighted_edges_from([(o.replace('MIN.','').strip(),d.replace('MIN.','').strip(),di['weight']) for o,d,di in GM.edges_iter(data=True)])
P.figure()
nx.draw_spectral(GMA)
nx.write_graphml(GMA,'ministro_ministro.graphml')
nx.write_gml(GMA,'ministro_ministro.gml')
nx.write_pajek(GMA,'ministro_ministro.pajek')
nx.write_dot(GMA,'ministro_ministro.dot')
return GMA
开发者ID:Ralpbezerra,项目名称:Supremo,代码行数:31,代码来源:grafos.py
示例3: displayGraph
def displayGraph(self, g, label=False):
axon, sd = axon_dendrites(g)
sizes = node_sizes(g) * 50
if len(sizes) == 0:
print('Empty graph for cell. Make sure proto file has `*asymmetric` on top. I cannot handle symmetric compartmental connections')
return
weights = np.array([g.edge[e[0]][e[1]]['weight'] for e in g.edges()])
pos = nx.graphviz_layout(g, prog='twopi')
xmin, ymin, xmax, ymax = 1e9, 1e9, -1e9, -1e9
for p in list(pos.values()):
if xmin > p[0]:
xmin = p[0]
if xmax < p[0]:
xmax = p[0]
if ymin > p[1]:
ymin = p[1]
if ymax < p[1]:
ymax = p[1]
edge_widths = 10.0 * weights / max(weights)
node_colors = ['k' if x in axon else 'gray' for x in g.nodes()]
lw = [1 if n.endswith('comp_1') else 0 for n in g.nodes()]
self.axes.clear()
try:
nx.draw_graphviz(g, ax=self.axes, prog='twopi', node_color=node_colors, lw=lw)
except (NameError, AttributeError) as e:
nx.draw_spectral(g, ax=self.axes, node_color=node_colors, lw=lw, with_labels=False, )
开发者ID:BhallaLab,项目名称:moose-examples,代码行数:26,代码来源:gui.py
示例4: draw_networkx_ex
def draw_networkx_ex():
G = nx.dodecahedral_graph()
nx.draw(G)
plt.show()
nx.draw_networkx(G, pos=nx.spring_layout(G))
limits = plt.axis('off')
plt.show()
nodes = nx.draw_networkx_nodes(G, pos=nx.spring_layout(G))
plt.show()
edges = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))
plt.show()
labels = nx.draw_networkx_labels(G, pos=nx.spring_layout(G))
plt.show()
edge_labels = nx.draw_networkx_edge_labels(G, pos=nx.spring_layout(G))
plt.show()
print("Circular layout")
nx.draw_circular(G)
plt.show()
print("Random layout")
nx.draw_random(G)
plt.show()
print("Spectral layout")
nx.draw_spectral(G)
plt.show()
print("Spring layout")
nx.draw_spring(G)
plt.show()
print("Shell layout")
nx.draw_shell(G)
plt.show()
print("Graphviz")
开发者ID:szintakacseva,项目名称:MLTopic,代码行数:31,代码来源:nxdrawing.py
示例5: draw_graph
def draw_graph(self, G, node_list=None, edge_colour='k', node_size=15, node_colour='r', graph_type='spring',
back_bone=None, side_chains=None, terminators=None):
# determine nodelist
if node_list is None:
node_list = G.nodes()
# determine labels
labels = {}
for l_atom in G.nodes_iter():
labels[l_atom] = l_atom.symbol
# draw graphs based on graph_type
if graph_type == 'circular':
nx.draw_circular(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
edge_color=edge_colour, node_color=node_colour)
elif graph_type == 'random':
nx.draw_random(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
edge_color=edge_colour, node_color=node_colour)
elif graph_type == 'spectral':
nx.draw_spectral(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
edge_color=edge_colour, node_color=node_colour)
elif graph_type == 'spring':
nx.draw_spring(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
edge_color=edge_colour, node_color=node_colour)
elif graph_type == 'shell':
nx.draw_shell(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
edge_color=edge_colour, node_color=node_colour)
# elif graph_type == 'protein':
# self.draw_protein(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
# edge_color=edge_colour, node_color=node_colour, back_bone, side_chains, terminators)
else:
nx.draw_networkx(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
edge_color=edge_colour, node_color=node_colour)
plt.show()
开发者ID:cjforman,项目名称:pele,代码行数:33,代码来源:molecule.py
示例6: tweet_flow
def tweet_flow():
global graph
print "Incoming Tweets!"
hashtag_edges = []
hastag_edges = get_edges_from_pairs(genereate_tags())
graph = max(nx.connected_component_subgraphs(graph), key=len)
for i in hastag_edges:
if i[0] != i[1] and len(i[0]) > len(i[1]):
graph.add_edge(i[0],i[1])
calc_average_degree()
nx.draw_spectral(graph,
node_size = 300,
width = 100,
node_color = '#A0CBE2', #light blue
edge_color = '#4169E1', #royal blue
font_size = 10,
with_labels = True )
plt.draw()
plt.pause(0.001)
time.sleep(60)
graph.clear()
tweet_flow()
开发者ID:onurtimur,项目名称:hgraph-from-tweets,代码行数:28,代码来源:tweet_clean_and_average.py
示例7: draw_spectral_communities
def draw_spectral_communities(self):
partition = self.find_partition()[1]
node_color=[float(partition[v]) for v in partition]
labels = self.compute_labels()
nx.draw_spectral(self.G,node_color=node_color, labels=labels)
plt.show()
plt.savefig("C:\\Users\\Heschoon\\Dropbox\\ULB\\Current trends of artificial intelligence\\Trends_project\\graphs\\graph_spectral.pdf")
开发者ID:HelainSchoonjans,项目名称:FacebookExperiments,代码行数:7,代码来源:social_graph.py
示例8: visualisation
def visualisation(chain, pairs):
G = nx.Graph()
a = range(len(chain))
G.add_edges_from([(i, i + 1) for i in a[:-1]])
G.add_edges_from(pairs)
nx.draw_spectral(G)
plt.show()
开发者ID:jbalcerz,项目名称:nussinov,代码行数:9,代码来源:nussinovMain.py
示例9: demo_save_fig
def demo_save_fig():
"""demo_save_fig"""
g = nx.Graph()
g.add_edges_from([(1, 2), (1, 3)])
g.add_node('sparm')
nx.draw(g)
nx.draw_random(g)
nx.draw_circular(g)
nx.draw_spectral(g)
plt.savefig("g.png")
开发者ID:gree2,项目名称:hobby,代码行数:10,代码来源:demo.plot.py
示例10: drawGraph
def drawGraph():
time.sleep(15)
log.info("Network's topology graph:")
nx.draw_spectral(g)
nx.draw_networkx_edge_labels(g,pos=nx.spectral_layout(g))
#nx.draw_circular(g)
#nx.draw_networkx_edge_labels(g,pos=nx.circular_layout(g))
#nx.draw_shell(g)
#nx.draw_networkx_edge_labels(g,pos=nx.shell_layout(g))
plt.show()
开发者ID:josecastillolema,项目名称:smart-OF-controller,代码行数:10,代码来源:dtsa2.py
示例11: main
def main():
print("Graphing!")
G = nx.Graph()
G.add_nodes_from([1-3])
G.add_edge(1, 2)
nx.draw_random(G)
nx.draw_circular(G)
nx.draw_spectral(G)
plt.show()
开发者ID:gorhack,项目名称:packet_malware,代码行数:10,代码来源:Grapher.py
示例12: test_draw
def test_draw(self):
# hold(False)
N=self.G
nx.draw_spring(N)
pylab.savefig("test.png")
nx.draw_random(N)
pylab.savefig("test.ps")
nx.draw_circular(N)
pylab.savefig("test.png")
nx.draw_spectral(N)
pylab.savefig("test.png")
开发者ID:JaneliaSciComp,项目名称:Neuroptikon,代码行数:11,代码来源:test_pylab.py
示例13: demo_write_doc
def demo_write_doc():
"""demo_write_doc"""
g = nx.Graph()
g.add_edges_from([(1, 2), (1, 3)])
g.add_node('sparm')
nx.draw(g)
nx.draw_random(g)
nx.draw_circular(g)
nx.draw_spectral(g)
nx.draw_graphviz(g)
nx.write_dot(g, 'g.dot')
开发者ID:gree2,项目名称:hobby,代码行数:11,代码来源:demo.plot.py
示例14: drawGraph
def drawGraph():
time.sleep(15)
log.info("Network's topology graph:")
log.info(' -> ingress switches: {}'.format(list(ingress)))
log.info(' -> egress switches: {}'.format(list(egress)))
nx.draw_spectral(graph)
nx.draw_networkx_edge_labels(graph, pos=nx.spectral_layout(graph))
#nx.draw_circular(graph)
#nx.draw_networkx_edge_labels(graph, pos=nx.circular_layout(graph))
#nx.draw_shell(graph)
#nx.draw_networkx_edge_labels(graph, pos=nx.shell_layout(graph))
plt.show()
开发者ID:josecastillolema,项目名称:smart-OF-controller,代码行数:12,代码来源:dtsa-smart.py
示例15: displayGraph
def displayGraph(self, g, label=False):
axon, sd = axon_dendrites(g)
sizes = node_sizes(g) * 50
if len(sizes) == 0:
print('Empty graph for cell. Make sure proto file has `*asymmetric` on top. I cannot handle symmetric compartmental connections')
return
node_colors = ['k' if x in axon else 'gray' for x in g.nodes()]
lw = [1 if n.endswith('comp_1') else 0 for n in g.nodes()]
self.axes.clear()
try:
nx.draw_graphviz(g, ax=self.axes, prog='twopi', node_color=node_colors, lw=lw)
except (NameError, AttributeError) as e:
nx.draw_spectral(g, ax=self.axes, node_color=node_colors, lw=lw, with_labels=False, )
开发者ID:BhallaLab,项目名称:moose,代码行数:13,代码来源:gui.py
示例16: test_draw
def test_draw(self):
N=self.G
nx.draw_spring(N)
plt.savefig("test.ps")
nx.draw_random(N)
plt.savefig("test.ps")
nx.draw_circular(N)
plt.savefig("test.ps")
nx.draw_spectral(N)
plt.savefig("test.ps")
nx.draw_spring(N.to_directed())
plt.savefig("test.ps")
os.unlink('test.ps')
开发者ID:9cc9,项目名称:networkx,代码行数:13,代码来源:test_pylab.py
示例17: GirvanNewman
def GirvanNewman(G):
no_component = nx.number_connected_components(G) #number of components
print("Number of components: ", no_component)
number_comp = no_component
while number_comp <= no_component: #while loop to partition graph into separate components
betweenness = nx.edge_betweenness_centrality(G) #edge betweenness
highest = max(betweenness.values()) #highest betweenness
print("Highest betweenness: ", highest)
for key, value in betweenness.items():
if float(value) == highest:
print("Edge removed ", key[0],key[1])
G.remove_edge(key[0],key[1]) #remove the edge with highest betweenness
nx.draw_spectral(G) #draw graph after edge removed
plt.show()
number_comp = nx.number_connected_components(G) #recalculate number of components
print("\nNumber of components: ", number_comp) #print number of components
开发者ID:hangreusch,项目名称:Networkx-python,代码行数:16,代码来源:karate_bc.py
示例18: to_nx_graph
def to_nx_graph(self, aut):
nx_graph = nx.MultiDiGraph(
autosize=False,
size="5.75,7.25",
ranksep="0.9",
splines=True,
sep="+5, 5",
overlap="false",
nodesep="0.2",
labelfontcolor="blue",
labelloc="t",
label=self.title_name,
)
nx_graph.add_nodes_from(
list(aut.states), height="0.4", width="0.4", color="pink", style="filled", fixedsize=False, fontsize="11"
)
for k in aut.transitions.keys():
for key, value in aut.transitions[k].items():
for v in value:
nx_graph.add_edge(
k,
v,
color=(self.color_set[2])
if (key == "#")
else (self.color_set[list(aut.char_set).index(key) % len(list(aut.char_set))]),
arrowsize=0.5,
labeldistance=2.5,
penwidth="0.8",
)
nx.draw_spectral(nx_graph)
gv_graph = to_agraph(nx_graph)
gv_graph.layout(prog="dot")
# prog=neato|dot|twopi|circo|fdp|nop
# set start & end states
for node in gv_graph.nodes():
if int(node.get_name()) in aut.e_states:
node.attr["color"] = "green"
node.attr["shape"] = "doublecircle"
elif int(node.get_name()) in aut.s_states:
node.attr["color"] = "blue"
node.attr["shape"] = "diamond"
gv_graph.draw("pics/" + str(self.pic_name) + ".png")
return gv_graph
开发者ID:shubhamshuklaer,项目名称:regex_matcher,代码行数:47,代码来源:gui.py
示例19: test_draw
def test_draw(self):
try:
N = self.G
nx.draw_spring(N)
plt.savefig('test.ps')
nx.draw_random(N)
plt.savefig('test.ps')
nx.draw_circular(N)
plt.savefig('test.ps')
nx.draw_spectral(N)
plt.savefig('test.ps')
nx.draw_spring(N.to_directed())
plt.savefig('test.ps')
finally:
try:
os.unlink('test.ps')
except OSError:
pass
开发者ID:4c656554,项目名称:networkx,代码行数:18,代码来源:test_pylab.py
示例20: __draw_dual_pivot__
def __draw_dual_pivot__(G, pos, width, height, pivot, mapping, node_size, pivot_color, pivot_label):
"""
Given a pivot, annotate it with color and label (handling duplicate if necessary) in dual.
:param G: Graph.
:param pos: position in canvas.
:param pivot: pivot dart.
:param mapping:
:param node_size: size of nodes in drawing.
:param pivot_color: pivot dart color.
:param pivot_label:
:return: Nothing.
"""
# Use different color for pivot dart (Handle boundary duplication if necessary).
pivot_dups = resolve_boundary_darts(
mapping[pivot.dual.tail.name], mapping[pivot.dual.head.name]) if pivot != None else []
pivot_dups = __remove_boundary_to_boundary_darts__(pivot_dups, width, height)
nx.draw_spectral(G,node_size=node_size,edgelist=pivot_dups,width=3,edge_color=pivot_color,node_color='white')
# Label pivot dart with pivot_label.
nx.draw_networkx_edge_labels(G, pos, edge_labels=__pivot_labels__(pivot_dups, pivot_label), label_pos=0.5)
开发者ID:lkhamsurenl,项目名称:research,代码行数:19,代码来源:draw_grid.py
注:本文中的networkx.draw_spectral函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论