Import Statementsfrom 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 GraphG = GSGraph()
| | G.add_node('a')
| | ..., label='A', ...)
| Label to display | ..., popup='html text', ...)
| Popup text | G.add_edge('a', 'b')
| | ..., directed=True, ...)
| Directed edge | ..., popup='html text', ...)
| Popup text | G.set_name('My Sample Graph')
| | G.set_tags(['sample'])
| |
Add Node StyleG.add_node_style('a', shape='ellipse')
| | ..., color='blue', ...)
| 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 StyleG.add_edge_style('a', 'b', edge_style='dotted')
| | ..., directed=True, ...)
| Directed edge | ..., color='#FF5733', ...)
| | ..., arrow_shape='tee', ...)
| | ..., width=4, ...)
| Edge width | ..., color='magenta', ...)
| Edge color | ..., arrow_fill='hollow', ...)
| | ..., width=4, ...)
| Edge width |
Arguments should be combined into one add_edge_style command.
Post Graph to GraphSpacegs = 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 itdef post(G, gs):
try:
graph = gs.update_graph(G)
except:
graph = gs.post_graph(G)
return graph
|
Fetch Posted Graphgraph = gs.get_graph(graph_name='My Sample Graph')
| | graph = gs.get_graph(graph_id=12345)
| Fetch by graph id | graph.name
| Name of graph | graph.id
| ID of graph |
Make Graph Publicgs.publish_graph(graph=graph)
| Make graph public | gs.unpublish_graph(graph=graph)
| Make graph private |
Groupsmygroup = 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 |
LayoutsL = GSLayout()
| | 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 | L.set_is_shared(1)
| 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