Import Statements
from graphspace_python.api.client import GraphSpace
|
from graphspace_python.graphs.classes.gsgraph import GSGraph
|
from graphspace_python.graphs.classes.gsgroup import GSGroup
|
from graphspace_python.graphs.classes.gslayout import GSLayout
|
Create a Graph
|
|
|
|
|
Label to display |
..., popup='html text', ...)
|
Popup text |
|
|
..., directed=True, ...)
|
Directed edge |
..., popup='html text', ...)
|
Popup text |
G.set_name('My Sample Graph')
|
|
G.set_tags(['sample'])
|
|
Add Node Style
G.add_node_style('a', shape='ellipse')
|
|
|
Node color |
..., color='#A152B8', ...)
|
|
..., bubble='blue', ...)
|
Bubble style |
..., height=40, width=20, ...)
|
Custom size |
..., style='dashed', ...)
|
|
..., border_color='red', ...)
|
Border color |
..., border_width=2, ...)
|
Border width |
Arguments should be combined into one add_node_style
command.
Add Edge Style
G.add_edge_style('a', 'b', edge_style='dotted')
|
|
..., directed=True, ...)
|
Directed edge |
..., color='#FF5733', ...)
|
|
..., arrow_shape='tee', ...)
|
|
|
Edge width |
..., color='magenta', ...)
|
Edge color |
..., arrow_fill='hollow', ...)
|
|
|
Edge width |
Arguments should be combined into one add_edge_style
command.
Post Graph to GraphSpace
gs = GraphSpace('uname', 'psswd')
|
|
graph = gs.post_graph(G)
|
Post (new) graph to GraphSpace |
graph = gs.update_graph(G)
|
Update (existing) graph to GraphSpace |
gs.delete_graph(graph=graph)
|
Delete graph from GraphSpace |
|
|
Update Graph if it Exists, Otherwise Post it
def post(G, gs):
try:
graph = gs.update_graph(G)
except:
graph = gs.post_graph(G)
return graph
|
Fetch Posted Graph
graph = gs.getÂ_grÂaphÂ(grÂaphÂ_naÂme='My Sample Graph')
|
|
graph = gs.getÂ_grÂaphÂ(grÂaphÂ_id=12345)
|
Fetch by graph id |
|
Name of graph |
|
ID of graph |
Make Graph Public
gs.publish_graph(graph=graph)
|
Make graph public |
gs.unpublish_graph(graph=graph)
|
Make graph private |
Groups
mygroup = GSGroup(name='My group', description='sample group')
|
|
group = gs.post_group(mygroup)
|
Add group |
group = gs.get_group(group_name='My group')
|
Fetch group |
gs.share_graph(graph=graph, group_name='My group')
|
Share graph with group |
gs.unshare_graph(graph=graph, group_name='My group')
|
Remove graph from group |
Layouts
|
|
L.set_node_position('a', y=38.5, x=67.3)
|
Set x and y coords |
L.add_node_style()
, L.add_edge_style()
|
Add styles in layout |
L.set_name('My Sample Layout')
|
Layout name |
|
Visible to members who can see graph |
layout = graphspace.post_graph_layout(L, graph=graph)
|
Post (new) layout |
layout = graphspace.get_graph_layout(layout_name='My Sample Layout', graph=graph)
|
Fetch layout |
layout1 = graphspace.update_graph_layout(layout)
|
Update (existing) layout |
Graphs usually have manually-determined layouts from GraphSpace, which are saved through the user interface.
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets