Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

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

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

Quickstart

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:
result of quickstart.py

Acknowledgements

Project structure generated from cookiecutter templatecookiecutter-python-project

About

A small library that makes it easy to create graph-tool-compliant graphs

Topics

Resources

License

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp