Differences between revisions 1 and 12 (spanning 11 versions)
Revision 1 as of 2006-11-02 05:49:07
Size: 1049
Editor: anonymous
Comment:
Revision 12 as of 2007-02-16 05:47:47
Size: 1837
Editor: anonymous
Comment:
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
The SAGE [http://sage.math.washington.edu:9001/graph Graph Theory Project] aims to implement Graph objects and algorithms in ["SAGE"].
Line 9: Line 7:
I'm integrating graph plotting fucntionality in ["SAGE"] one piece at a time. == 2D Plotting ==
Line 11: Line 9:
So far, after small revisions to the graphics class, I've written a NetworkX primitive that takes a NetworkX graph on initialization, and renders that graph using NetworkX's native spring layout routine. In this routine, each edge is treated as a spring; after each node is randomly placed on the plot screen, fifty iterations allow the "springs" to align themselves in equilibrium, often revealing geometric symmetries of the graph (try plotting a Platonic solid...). This is only the beginning of a true graph plotting interface, since there must be routines and objects that will deal with a soon-coming ["SAGE"] graph class. When completed, this NetworkX primitive should take advantage of as much NetworkX functionality as possible.  * matplotlib plotting is supported (albeit awkwardly) by NetworkX. Smooth interfacing of this functionality with SAGE (especially the notebook) is almost complete. Part of this implementation was writing a NetworkX graphics primitive. In this routine, each edge is treated as a spring; after each node is randomly placed on the plot screen, fifty iterations allow the "springs" to align themselves in equilibrium, often revealing geometric symmetries of the graph (try plotting a Platonic solid...). There are also options to pre-specify vertex positions: the graph class now comes with an optional positioning variable, so that if a user likes to think of a graph in a certain visual layout, that layout can be made part of the graph information. Boundary nodes default to plot a different color, and edge labels will soon be displayed. Pending another graphics primitive, graphics objects can be associated with nodes so that the plots show up in place of the nodes when a graph is displayed.

 * Examples:

{{{
graphs.PetersenGraph().show()
}}}
attachment:petersen.png

{{{
graphs.CubeGraph(5).show(vertex_labels=False, node_size=100)
}}}
attachment:5-cube.png

{{{
graphs.CubeGraph(4).show(layout='spring')
}}}
attachment:4-cube.png

{{{
d = {}
for j in range(14):
    h = (j/14)*6
    i = floor(h)
    a = h - i; b = 1 - a # a==var3, b==var2
    r = { 0: 1, 1: b, 2: 0, 3: 0, 4: a, 5: 1 }[i]
    g = { 0: a, 1: 1, 2: 1, 3: b, 4: 0, 5: 0 }[i]
    b = { 0: 0, 1: 0, 2: a, 3: 1, 4: 1, 5: b }[i]
    d[(r, g, b)] = [j]
graphs.HeawoodGraph().show(color_dict=d)
}}}
attachment:heawood.png

{{{
G = graphs.FlowerSnark()
G.set_boundary([15,16,17,18,19])
G.show()
}}}
attachment:snark.png

TableOfContents

Introduction

Robert Miller is working on this project.

2D Plotting

  • matplotlib plotting is supported (albeit awkwardly) by NetworkX. Smooth interfacing of this functionality with SAGE (especially the notebook) is almost complete. Part of this implementation was writing a NetworkX graphics primitive. In this routine, each edge is treated as a spring; after each node is randomly placed on the plot screen, fifty iterations allow the "springs" to align themselves in equilibrium, often revealing geometric symmetries of the graph (try plotting a Platonic solid...). There are also options to pre-specify vertex positions: the graph class now comes with an optional positioning variable, so that if a user likes to think of a graph in a certain visual layout, that layout can be made part of the graph information. Boundary nodes default to plot a different color, and edge labels will soon be displayed. Pending another graphics primitive, graphics objects can be associated with nodes so that the plots show up in place of the nodes when a graph is displayed.
  • Examples:

graphs.PetersenGraph().show()

attachment:petersen.png

graphs.CubeGraph(5).show(vertex_labels=False, node_size=100)

attachment:5-cube.png

graphs.CubeGraph(4).show(layout='spring')

attachment:4-cube.png

d = {}
for j in range(14):
    h = (j/14)*6
    i = floor(h)
    a = h - i; b = 1 - a # a==var3, b==var2
    r = { 0: 1, 1: b, 2: 0, 3: 0, 4: a, 5: 1 }[i]
    g = { 0: a, 1: 1, 2: 1, 3: b, 4: 0, 5: 0 }[i]
    b = { 0: 0, 1: 0, 2: a, 3: 1, 4: 1, 5: b }[i]
    d[(r, g, b)] = [j]
graphs.HeawoodGraph().show(color_dict=d)

attachment:heawood.png

G = graphs.FlowerSnark()
G.set_boundary([15,16,17,18,19])
G.show()

attachment:snark.png

graph_plotting (last edited 2008-11-14 13:42:15 by anonymous)