Sharedsupport / 2015-04-04-105124-digraph.sagewsOpen in CoCalc
Authors: Harald Schilly, ℏal Snyder, William A. Stein
License: GNU General Public License v3.0
Description: Examples for support purposes.
g = DiGraph({42 : [4,15], 4 : [3,5],3:[10,11], 15 : [7], 5:[12,13],10:[],11:[14]}) show(g)
d3-based renderer not yet implemented
import graphics; graphics.graph_to_d3_jsonable?
File: /projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/.sagemathcloud/ Signature : graphics.graph_to_d3_jsonable(G, vertex_labels=True, edge_labels=False, vertex_partition=[], edge_partition=[], force_spring_layout=False, charge=-120, link_distance=50, link_strength=1, gravity=0.04, vertex_size=7, edge_thickness=2, width=None, height=None, **kwds) Docstring : Display a graph in SageMathCloud using the D3 visualization library. INPUT: * "G" -- the graph * "vertex_labels" (boolean) -- Whether to display vertex labels (set to "True" by default). * "edge_labels" (boolean) -- Whether to display edge labels (set to "False" by default). * "vertex_partition" -- a list of lists representing a partition of the vertex set. Vertices are then colored in the graph according to the partition. Set to "[]" by default. * "edge_partition" -- same as "vertex_partition", with edges instead. Set to "[]" by default. * "force_spring_layout" -- whether to take sage's position into account if there is one (see "()" and "()"), or to compute a spring layout. Set to "False" by default. * "vertex_size" -- The size of a vertex' circle. Set to 7 by default. * "edge_thickness" -- Thickness of an edge. Set to "2" by default. * "charge" -- the vertices' charge. Defines how they repulse each other. See for more information. Set to "-120" by default. * "link_distance" -- See Layout for more information. Set to "30" by default. * "link_strength" -- See Layout for more information. Set to "1.5" by default. * "gravity" -- See Layout for more information. Set to "0.04" by default. EXAMPLES: show(graphs.RandomTree(50), d3=True) show(graphs.PetersenGraph(), d3=True, vertex_partition=g.coloring()) show(graphs.DodecahedralGraph(), d3=True, force_spring_layout=True) show(graphs.DodecahedralGraph(), d3=True) g = digraphs.DeBruijn(2,2) g.allow_multiple_edges(True) g.add_edge("10","10","a") g.add_edge("10","10","b") g.add_edge("10","10","c") g.add_edge("10","10","d") g.add_edge("01","11","1") show(g, d3=True, vertex_labels=True,edge_labels=True, link_distance=200,gravity=.05,charge=-500, edge_partition=[[("11","12","2"),("21","21","a")]], edge_thickness=4)
show(g, d3=False)