- Notifications
You must be signed in to change notification settings - Fork0
A small library that makes it easy to create graph-tool-compliant graphs
License
NotificationsYou must be signed in to change notification settings
gkostkowski/gt-pg
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Library for creation and management of graphs with vertex and edge properties,usesGraph-tool as the underlying graph library.gt-pg library also allows to access graph-tool objects.
Graph-tool Property Graph is available on custom CLARIN PyPI repository and can beinstalled withpip.
$ pip install --ignore-installed --extra-index-url https://pypi.clarin-pl.eu/ gt-pg
After installing Graph-tool Property Graph you can use it like any otherPython module.
Here is a simple usage demonstrating usage of gt-pg package(quickstart.py):
importgt_pg# prepare data for simple graph:# prepare names of properties of certain typesvertex_properties= {"uri":"string","label":"string",}edge_properties= {"uri":"string","label":"string",}# prepare values for uris, the keys for vertices and edgesv_id_prop="uri"e_id_prop="uri"v_uris= ["http://example.com/1","http://example.com/2","http://example.com/3"]e_uris= ["http://example.com/relA","http://example.com/relB"]# initialize the graphg=gt_pg.Graph()g.init_graph(v_props=vertex_properties,e_props=edge_properties,)g.set_vertex_id_prop(v_id_prop)g.set_edge_id_prop(e_id_prop)# specify properties for vertices, vertices will be createdg.append_vprop_val(v_uris[0],"label","1")g.append_vprop_val(v_uris[2],"label","3")# create relation between vertices, non-existing vertices will be createdg.create_relation(v_uris[0],v_uris[1],e_uris[0])g.create_relation(v_uris[2],v_uris[1],e_uris[1])# specify property for edgeg.append_eprop_val(v_uris[2],v_uris[1],"label","relA")# save graphg.save('quickstart.graphml')
Above snippet generates following graph:
Project structure generated from cookiecutter templatecookiecutter-python-project
About
A small library that makes it easy to create graph-tool-compliant graphs