# Changeset 5340:16943a99d1ba

Ignore:
Timestamp:
06/14/07 03:12:38 (6 years ago)
Branch:
default
Message:

consistency

Location:
sage
Files:
6 edited

Unmodified
Removed
• ## sage/graphs/graph.py

 r5339 (2007-06-07--09): NetworkX function wrapping -- Michael W. Hansen (2007-06-09): Topological sort generation -- Emily Kirkman, Robert L. Miller SAGE Days 4: Finished wrapping NetworkX TUTORIAL: sage: (graphs.ChvatalGraph()).cliques_get_max_clique_graph() Graph on 24 vertices sage.: ((graphs.ChvatalGraph()).cliques_get_max_clique_graph()).show(figsize=[2,2], node_size=20, vertex_labels=False) sage.: ((graphs.ChvatalGraph()).cliques_get_max_clique_graph()).show(figsize=[2,2], vertex_size=20, vertex_labels=False) sage: D = DiGraph({0:[1,2,3], 1:[2], 3:[0,1]}) sage.: D.show(figsize=[2,2]) sage: (graphs.ChvatalGraph()).cliques_get_clique_bipartite() Graph on 36 vertices sage.: ((graphs.ChvatalGraph()).cliques_get_clique_bipartite()).show(figsize=[2,2], node_size=20, vertex_labels=False) sage.: ((graphs.ChvatalGraph()).cliques_get_clique_bipartite()).show(figsize=[2,2], vertex_size=20, vertex_labels=False) sage: D = DiGraph({0:[1,2,3], 1:[2], 3:[0,1]}) sage.: D.show(figsize=[2,2]) def plot(self, pos=None, layout=None, vertex_labels=True, edge_labels=False, node_size=200, graph_border=False, color_dict=None, partition=None, vertex_size=200, graph_border=False, color_dict=None, partition=None, edge_colors=None, scaling_term=0.05, xmin=None, xmax=None):  # xmin and xmax are ignored """ edge_labels -- whether to print edge(arc) labels. By default, False, but if True, the result of str(l) is printed on the edge for each label l. Labels equal to None are not printed. node_size -- size of vertices displayed vertex_size -- size of vertices displayed graph_border -- whether to include a box around the graph color_dict -- optional dictionary to specify vertex colors: each key is a color recognizable sage: C = graphs.CubeGraph(8) sage: P = C.plot(vertex_labels=False, node_size=0, graph_border=True) sage: P = C.plot(vertex_labels=False, vertex_size=0, graph_border=True) sage: P.save('sage.png') ...        if u[i] != v[i]: ...            edge_colors[R[i]].append((u,v,l)) sage: C.plot(vertex_labels=False, node_size=0, edge_colors=edge_colors).save('sage.png') sage: C.plot(vertex_labels=False, vertex_size=0, edge_colors=edge_colors).save('sage.png') """ for a in range(len(pos[v])): pos[v][a] = float(pos[v][a]) G = networkx_plot(self._nxg, pos=pos, vertex_labels=vertex_labels, node_size=node_size, color_dict=color_dict, edge_colors=edge_colors, graph_border=graph_border, scaling_term=scaling_term) G = networkx_plot(self._nxg, pos=pos, vertex_labels=vertex_labels, vertex_size=vertex_size, color_dict=color_dict, edge_colors=edge_colors, graph_border=graph_border, scaling_term=scaling_term) if edge_labels: from sage.plot.plot import text return G def show(self, pos=None, layout=None, vertex_labels=True, edge_labels=False, node_size=200, def show(self, pos=None, layout=None, vertex_labels=True, edge_labels=False, vertex_size=200, graph_border=False, color_dict=None, edge_colors=None, partition=None, scaling_term=0.05, talk=False, **kwds): edge_labels -- whether to print edge(arc) labels. By default, False, but if True, the result of str(l) is printed on the edge for each label l. Labels equal to None are not printed. node_size -- size of vertices displayed vertex_size -- size of vertices displayed graph_border -- whether to include a box around the graph color_dict -- optional dictionary to specify vertex colors: each key is a color recognizable sage: C = graphs.CubeGraph(8) sage: P = C.plot(vertex_labels=False, node_size=0, graph_border=True) sage: P = C.plot(vertex_labels=False, vertex_size=0, graph_border=True) sage: P.save('sage.png') ...        if u[i] != v[i]: ...            edge_colors[R[i]].append((u,v,l)) sage: C.plot(vertex_labels=False, node_size=0, edge_colors=edge_colors).save('sage.png') sage: C.plot(vertex_labels=False, vertex_size=0, edge_colors=edge_colors).save('sage.png') """ if talk: node_size = 500 vertex_size = 500 if partition is None: color_dict = {'#FFFFFF':self.vertices()} self.plot(pos=pos, layout=layout, vertex_labels=vertex_labels, edge_labels=edge_labels, node_size=node_size, color_dict=color_dict, edge_colors=edge_colors, graph_border=graph_border, partition=partition, scaling_term=scaling_term).show(**kwds) self.plot(pos=pos, layout=layout, vertex_labels=vertex_labels, edge_labels=edge_labels, vertex_size=vertex_size, color_dict=color_dict, edge_colors=edge_colors, graph_border=graph_border, partition=partition, scaling_term=scaling_term).show(**kwds) class Graph(GenericGraph): sage: SD.set_arc_label(14, 15, 'v_k m.c.r.') sage: posn = {1:[ 3,-3],  2:[0,2],  3:[0, 13],  4:[3,9],  5:[3,3],  6:[16, 13], 7:[6,1],  8:[6,6],  9:[6,11], 10:[9,1], 11:[10,6], 12:[13,6], 13:[16,2], 14:[10,-6], 15:[0,-10], 16:[14,-6], 17:[16,-10], 18:[6,-4]} sage: SD.plot(pos=posn, node_size=400, color_dict={'#FFFFFF':range(1,19)}, edge_labels=True).save('search_tree.png') sage: SD.plot(pos=posn, vertex_size=400, color_dict={'#FFFFFF':range(1,19)}, edge_labels=True).save('search_tree.png') """
• ## sage/graphs/graph_database.py

 r4713 # The following line is time consuming and should not stay: graph6list.append(g.graph6_string()) p = g.plot(layout=layout, node_size=30, vertex_labels=False, graph_border=False) p = g.plot(layout=layout, vertex_size=30, vertex_labels=False, graph_border=False) p.save('%s.png'%i, figsize=[1,1]) # The following line is time consuming and should not stay: graph6list.append(g.graph6_string()) p = g.plot(layout=layout, node_size=30, vertex_labels=False, graph_border=False) p = g.plot(layout=layout, vertex_size=30, vertex_labels=False, graph_border=False) p.save('%s.png'%i, figsize=[1,1]) # The following line is time consuming and should not stay: graph6list.append(g.graph6_string()) p = g.plot(layout=layout, node_size=30, vertex_labels=False, graph_border=False) p = g.plot(layout=layout, vertex_size=30, vertex_labels=False, graph_border=False) p.save('%s.png'%i, figsize=[1,1]) sage: len(g) 1 sage.: g[0].show(layout='circular',figsize=[2,2],node_size=0,graph_border=True) sage.: g[0].show(layout='circular',figsize=[2,2],vertex_size=0,graph_border=True) sage: g = graphs_query.get_list(degree_sequence=433211) sage: graphs_list.to_graph6(g)
• ## sage/graphs/graph_generators.py

 r5335 ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(2): ...        n.append(g[i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) sage: G = sage.plot.plot.GraphicsArray(j) ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... Use the plot options to display larger n-cubes sage: g = graphs.CubeGraph(9) sage.: g.show(figsize=[12,12],vertex_labels=False, node_size=20) sage.: g.show(figsize=[12,12],vertex_labels=False, vertex_size=20) """ from sage.rings.integer import Integer ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ... ...    n = [] ...    for m in range(3): ...        n.append(g[3*i + m].plot(node_size=50, vertex_labels=False)) ...        n.append(g[3*i + m].plot(vertex_size=50, vertex_labels=False)) ...    j.append(n) ...
• ## sage/graphs/graph_isom.pyx

 r5318 sage: SD.set_arc_label(14, 15, 'v_k m.c.r.') sage: posn = {1:[ 3,-3],  2:[0,2],  3:[0, 13],  4:[3,9],  5:[3,3],  6:[16, 13], 7:[6,1],  8:[6,6],  9:[6,11], 10:[9,1], 11:[10,6], 12:[13,6], 13:[16,2], 14:[10,-6], 15:[0,-10], 16:[14,-6], 17:[16,-10], 18:[6,-4]} sage: SD.plot(pos=posn, node_size=400, color_dict={'#FFFFFF':range(1,19)}, edge_labels=True).save('search_tree.png') sage: SD.plot(pos=posn, vertex_size=400, color_dict={'#FFFFFF':range(1,19)}, edge_labels=True).save('search_tree.png') EXAMPLES:
• ## sage/graphs/graph_list.py

 r5333 pos = list[i].__get_pos__() if ( pos is None ): plist.append(list[i].plot(layout='circular', node_size=50, vertex_labels=False, graph_border=True)) else: plist.append(list[i].plot(pos=pos, node_size=50, vertex_labels=False, graph_border=True)) plist.append(list[i].plot(layout='circular', vertex_size=50, vertex_labels=False, graph_border=True)) else: plist.append(list[i].plot(pos=pos, vertex_size=50, vertex_labels=False, graph_border=True)) else:  raise TypeError, 'Param list must be a list of SAGE graphs.'
• ## sage/plot/plot.py

 r4525 4: [-1.125     ,-0.50118505,]   } vertex_labels -- determines whether labels for nodes are plotted node_size -- node size vertex_size -- node size color_dict -- a dictionary specifying node colors: each key is a color recognized by matplotlib, and each entry is a list of vertices. ...        if u[i] != v[i]: ...            edge_colors[R[i]].append((u,v,l)) sage: NGP = GraphicPrimitive_NetworkXGraph(G, pos=pos, vertex_labels=False, node_size=0, edge_colors=edge_colors) sage: NGP = GraphicPrimitive_NetworkXGraph(G, pos=pos, vertex_labels=False, vertex_size=0, edge_colors=edge_colors) sage: G = Graphics() sage: G.append(NGP) sage: G.save('sage.png') """ def __init__(self, graph, pos=None, vertex_labels=True, node_size=300, color_dict=None, edge_colors=None, scaling_term=0.05): def __init__(self, graph, pos=None, vertex_labels=True, vertex_size=300, color_dict=None, edge_colors=None, scaling_term=0.05): self.__nxg = graph self.__node_size = node_size self.__vertex_size = vertex_size self.__vertex_labels = vertex_labels self.__color_dict = color_dict if len(self.__nxg) != 0: import networkx as NX node_size = float(self.__node_size) vertex_size = float(self.__vertex_size) if self.__color_dict is None: NX.draw_networkx_nodes(G=self.__nxg, pos=self.__pos, ax=subplot, node_size=node_size) NX.draw_networkx_nodes(G=self.__nxg, pos=self.__pos, ax=subplot, node_size=vertex_size) else: for i in self.__color_dict: NX.draw_networkx_nodes(G=self.__nxg, nodelist=self.__color_dict[i], node_color=i, pos=self.__pos, ax=subplot, node_size=node_size) NX.draw_networkx_nodes(G=self.__nxg, nodelist=self.__color_dict[i], node_color=i, pos=self.__pos, ax=subplot, node_size=vertex_size) if self.__edge_colors is None: NX.draw_networkx_edges(G=self.__nxg, pos=self.__pos, ax=subplot, node_size=node_size) NX.draw_networkx_edges(G=self.__nxg, pos=self.__pos, ax=subplot, node_size=vertex_size) else: for i in self.__edge_colors: NX.draw_networkx_edges(G=self.__nxg, pos=self.__pos, edgelist=self.__edge_colors[i], edge_color=i, ax=subplot, node_size=node_size) NX.draw_networkx_edges(G=self.__nxg, pos=self.__pos, edgelist=self.__edge_colors[i], edge_color=i, ax=subplot, node_size=vertex_size) if self.__vertex_labels: labels = {} return P def networkx_plot(graph, pos=None, vertex_labels=True, node_size=300, color_dict=None, def networkx_plot(graph, pos=None, vertex_labels=True, vertex_size=300, color_dict=None, edge_colors=None, graph_border=False, scaling_term=0.05): """ 4: [-1.125     ,-0.50118505,]   } vertex_labels -- determines whether labels for nodes are plotted node_size -- node size vertex_size -- node size color_dict -- a dictionary specifying node colors: each key is a color recognized by matplotlib, and each entry is a list of vertices. ...        if u[i] != v[i]: ...            edge_colors[R[i]].append((u,v,l)) sage: P = networkx_plot(C._nxg, pos=C.__get_pos__(), edge_colors=edge_colors, vertex_labels=False, node_size=0) sage: P = networkx_plot(C._nxg, pos=C.__get_pos__(), edge_colors=edge_colors, vertex_labels=False, vertex_size=0) sage: P.save('sage.png') """ g = Graphics() NGP = GraphicPrimitive_NetworkXGraph(graph, pos=pos, vertex_labels=vertex_labels, node_size=node_size, color_dict=color_dict, edge_colors=edge_colors, scaling_term=scaling_term) NGP = GraphicPrimitive_NetworkXGraph(graph, pos=pos, vertex_labels=vertex_labels, vertex_size=vertex_size, color_dict=color_dict, edge_colors=edge_colors, scaling_term=scaling_term) g.append(NGP) xmin = NGP._xmin
Note: See TracChangeset for help on using the changeset viewer.