{"id":16393503,"url":"https://github.com/iamaziz/pygraph","last_synced_at":"2025-05-07T17:01:52.249Z","repository":{"id":27748009,"uuid":"31235947","full_name":"iamaziz/pygraph","owner":"iamaziz","description":"Create simple and quick Directed Graphs from relational statements.","archived":false,"fork":false,"pushed_at":"2015-04-27T05:48:26.000Z","size":360,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T00:38:11.454Z","etag":null,"topics":["directed-graph","knowledge-graph","pydot","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamaziz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-23T23:37:51.000Z","updated_at":"2024-04-30T10:33:53.000Z","dependencies_parsed_at":"2022-09-03T05:11:03.713Z","dependency_job_id":null,"html_url":"https://github.com/iamaziz/pygraph","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamaziz%2Fpygraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamaziz%2Fpygraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamaziz%2Fpygraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamaziz%2Fpygraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamaziz","download_url":"https://codeload.github.com/iamaziz/pygraph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252922027,"owners_count":21825633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["directed-graph","knowledge-graph","pydot","python"],"created_at":"2024-10-11T04:53:25.780Z","updated_at":"2025-05-07T17:01:52.194Z","avatar_url":"https://github.com/iamaziz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pygraph \n=======\n\npygraph creates simple and quick `Directed Graphs` using relational sentences (knowledge base). It uses [pydot](https://pypi.python.org/pypi/pydot/1.0.28) for rendering the graphs.\n\nThe concept of this module is based on the ontological relationships, or Linked Data. \n \n Means we don't need to create nodes then link them to one another separately, \n but instead we will introduce new relations between nodes through statements, let's call them `relation statements`.\n \n For example, the relation statement `A likes B` this will be translated into a graph (fig. below) with two nodes `A` and `B` where the link (edge) \nbetween them is directed from `A` to `B` with the label `likes`. \n\n\n![A likes B](examples/img/relation.png)\n\n## How to use:\n\nNew relation statements can be introduced in two ways \n\n1. module level by using `add_relation('A likes B')` method, or \n2. from an external file where multiple relation statements can be parsed at once.\n\n#### Example:\n\n1) module level entry example:\n\n```python\nimport sys\nsys.path.append(\"../../pygraph\")\nfrom pygraph.dgraph import PyGraph\n\ng = PyGraph()\n\ng.add_relation('A likes B')\ng.add_relation('A dislikes C')\ng.add_relation('B loves C')\ng.add_relation('C likes A')\n\ng.draw_graph()\n\n```\nwill produce:\n\n![module level example](examples/img/ex1.png)\n\n\n\n2) Or you can read relations directly from an external file and pass its `path` as an argument for `pygraph/dgraph.py`.\n\ne.g.\n\nfile name `kb-person.csv` and its contents:\n\n```raw\nMan is-a Person\nWoman is-a Person\nChild is-a Person\nFather has Child\nMother has Child\nMother is-a Wife\nFather is-a Husband\nHusband marriedTo Wife\nWife marriedTo Husband\nHusband is-a Man\nWife is-a Woman\n```\n\nRun:\n\n`$ python pygraph/dgraph.py example/dataset/kb-person.csv` \n\nwill produce the following:\n\n![Simple Person Ontology](examples/img/ex2.png)\n\nFor help and options see `$ python pygraph/dgraph.py -h`\n\n## Requirements:\n\n- pydot 1.0.2+\n\n\n\n## To know:\n\n- Repeated relations between the same nodes are ignored.\n- Output will be saved into an output folder `pygraph-output`.\n- You may specify the delimiter in sentences (default is one space \" \"). \n- Tested on Python 2.7.6 and 3.4.2\n- To install `pydot` for:\n\t- python 3+ see [James Mills](https://code.google.com/p/pydot/#Support_for_Python_3) branch.\n\t- python 2 try `$ pip install pydot` or `$ sudo pip install pydot`\n\n## TO DO:\n\n- Test unit to validate the input `relation sentences`.\n- Add more arguments to `argparse` options.\n- Add `setup.py` and `requirements.txt` for installation.\n- Extend to more graph types.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamaziz%2Fpygraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamaziz%2Fpygraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamaziz%2Fpygraph/lists"}