{"id":23647082,"url":"https://github.com/wey-gu/nebula-shareholding-example","last_synced_at":"2025-08-31T22:32:27.585Z","repository":{"id":47034212,"uuid":"385850518","full_name":"wey-gu/nebula-shareholding-example","owner":"wey-gu","description":"A dataset generator/graph modeling demo of Shareholding Breakthrough with Distributed open-source Graph Database: Nebula Graph. 图数据库应用示例、数据集、图建模：股权关系穿透","archived":false,"fork":false,"pushed_at":"2024-04-20T05:05:32.000Z","size":4339,"stargazers_count":31,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-20T12:48:11.472Z","etag":null,"topics":["dataset","graphdatabase","nebula-graph"],"latest_commit_sha":null,"homepage":"https://siwei.io/nebula-holdshare-dataset/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wey-gu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-14T07:21:41.000Z","updated_at":"2024-11-21T06:32:47.000Z","dependencies_parsed_at":"2022-09-02T23:23:31.770Z","dependency_job_id":null,"html_url":"https://github.com/wey-gu/nebula-shareholding-example","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/wey-gu%2Fnebula-shareholding-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wey-gu%2Fnebula-shareholding-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wey-gu%2Fnebula-shareholding-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wey-gu%2Fnebula-shareholding-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wey-gu","download_url":"https://codeload.github.com/wey-gu/nebula-shareholding-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231633141,"owners_count":18403402,"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":["dataset","graphdatabase","nebula-graph"],"created_at":"2024-12-28T13:49:15.593Z","updated_at":"2024-12-28T13:49:16.115Z","avatar_url":"https://github.com/wey-gu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\nThis is a demo of Shareholding Breakthrough with Distributed open-source Graph Database: Nebula Graph.\n\n\u003e Generated dataset in two size(1K and 1M) is now ready in [Kaggle](https://www.kaggle.com/littlewey/nebula-graph-shareolding-dataset)\n\n## Data\n\n### Data Modeling\n\n![modeling](./images/modeling.png)\n\nThere are various kinds of relationships when we checking companies' shareholding breakthrough, here let's simplify it with only two kind of entities: person and corp, and with following relationship types.\n\n- `person` can hold a `corp` in `{share} %`\n- `person` can be relative with another `person`\n- `corp` can hold another `corp` in `{share} %`\n- `corp` can be a branch of another `corp`\n- `person` can be as a role of a `corp`\n\nBelow is the lines to reflect this graph modele in Nebula Graph, it's quite straightforward, right?\n\n```sql\nCREATE TAG person(name string);\nCREATE TAG corp(name string);\nCREATE EDGE role_as(role string);\nCREATE EDGE is_branch_of();\nCREATE EDGE hold_share(share float);\nCREATE EDGE reletive_with(degree int);\n```\n\n### Data Generation\n\nWe just randomly generate some data to help with this demo, you can call `data_generator.py` directly to generate or reuse what's already done under `data_sample` folder.\n\nThe generated data are records to be fit in above data model from below `.csv` files.\n\n```bash\n$ pip install Faker==2.0.5 pydbgen==1.0.5\n$ python3 data_generator.py\n$ ls -l data\ntotal 1688\n-rw-r--r--  1 weyl  staff   23941 Jul 14 13:28 corp.csv\n-rw-r--r--  1 weyl  staff    1277 Jul 14 13:26 corp_rel.csv\n-rw-r--r--  1 weyl  staff    3048 Jul 14 13:26 corp_share.csv\n-rw-r--r--  1 weyl  staff  211661 Jul 14 13:26 person.csv\n-rw-r--r--  1 weyl  staff  179770 Jul 14 13:26 person_corp_role.csv\n-rw-r--r--  1 weyl  staff  322965 Jul 14 13:26 person_corp_share.csv\n-rw-r--r--  1 weyl  staff   17689 Jul 14 13:26 person_rel.csv\n```\n\n### Data Import\n\nWith those data in `.csv` files, we can easily import them into a Nebula Graph Cluster with the help of [Nebula-Importer](https://github.com/vesoft-inc/nebula-importer). `nebula-importer.yaml` in this repo describes rules and configurations on how this import will be done by the importer.\n\nFor Nebula Graph Database, plesae refer to [Doc](https://docs.nebula-graph.io/) , [Doc-CN](https://docs.nebula-graph.com.cn/) to deploy on any Linux Servers, for study and test, you can run it via Docker following the Quick Start Chapter of the documentation.\n\nFor Nebula-Importer, if you already have Docker env, you can run it as the following without installing anything. Or, if you prefer to install it, it's quite easy as it's written in Golang and you can run its single file binary quite easily, go check both Documentation and Nebula-Importer Repo: https://github.com/vesoft-inc/nebula-importer.\n\n\u003e Let's start! Below is the commands I used to import our data into a Nebula Graph Database.\n\n```bash\n# put generated data \u0026 nebula-importor.yaml to nebula-importer server\n$ scp -r data nebula_graph_host:~\n$ scp nebula-importer.yaml data nebula_graph_host:~/data\n$ ssh nebula_graph_host\n$ ls -l ${HOME}/data\ntotal 756\n-rw-r--r--. 1 wei.gu wei.gu  23941 Jul 14 05:44 corp.csv\n-rw-r--r--. 1 wei.gu wei.gu   1277 Jul 14 05:44 corp_rel.csv\n-rw-r--r--. 1 wei.gu wei.gu   3048 Jul 14 05:44 corp_share.csv\n-rw-r--r--. 1 wei.gu wei.gu   3893 Jul 14 05:44 nebula-importer.yaml\n-rw-r--r--. 1 wei.gu wei.gu 211661 Jul 14 05:44 person.csv\n-rw-r--r--. 1 wei.gu wei.gu 179770 Jul 14 05:44 person_corp_role.csv\n-rw-r--r--. 1 wei.gu wei.gu 322965 Jul 14 05:44 person_corp_share.csv\n-rw-r--r--. 1 wei.gu wei.gu  17689 Jul 14 05:44 person_rel.csv\n\n# import data into our nebula graph database\n$ docker run --rm -ti \\\n    --network=nebula-docker-compose_nebula-net \\\n    -v ${HOME}/data/nebula-importer.yaml:/root/nebula-importer.yaml \\\n    -v ${HOME}/data:/root \\\n    vesoft/nebula-importer:v2 \\\n    --config /root/nebula-importer.yaml\n\n2021/07/14 05:49:32 --- START OF NEBULA IMPORTER ---\n2021/07/14 05:49:32 [WARN] config.go:491: Not set files[0].schema.vertex.vid.Type, reset to default value `string'\n...\n2021/07/14 05:49:43 [INFO] reader.go:180: Total lines of file(/root/person_corp_role.csv) is: 5000, error lines: 1287\n2021/07/14 05:49:43 [INFO] statsmgr.go:61: Done(/root/person_corp_role.csv): Time(11.39s), Finished(12523), Failed(0), Latency AVG(1514us), Batches Req AVG(1824us), Rows AVG(1099.43/s)\n2021/07/14 05:49:47 [INFO] statsmgr.go:61: Tick: Time(15.00s), Finished(25807), Failed(0), Latency AVG(1500us), Batches Req AVG(1805us), Rows AVG(1720.46/s)\n2021/07/14 05:49:48 [INFO] reader.go:180: Total lines of file(/root/person.csv) is: 10000, error lines: 0\n2021/07/14 05:49:48 [INFO] statsmgr.go:61: Done(/root/person.csv): Time(16.10s), Finished(29731), Failed(0), Latency AVG(1505us), Batches Req AVG(1810us), Rows AVG(1847.17/s)\n2021/07/14 05:49:50 [INFO] reader.go:180: Total lines of file(/root/person_corp_share.csv) is: 20000, error lines: 0\n2021/07/14 05:49:50 [INFO] statsmgr.go:61: Done(/root/person_corp_share.csv): Time(17.74s), Finished(36013), Failed(0), Latency AVG(1531us), Batches Req AVG(1844us), Rows AVG(2030.29/s)\n2021/07/14 05:49:50 Finish import data, consume time: 18.25s\n2021/07/14 05:49:51 --- END OF NEBULA IMPORTER ---\n```\n\n\n\n## Corporation sharehold relationship breakthrough\n\n#### Query in nGQL\n\nWe can query from corp: `c_132` over `*`(all relationships) in `BIDIRECT`:\n\n```sql\nGO 1 TO 3 STEPS FROM \"c_132\" over * BIDIRECT\n```\n\nBelow are lines I call this query in [nebula-console](https://github.com/vesoft-inc/nebula-console):\n\n```bash\n/ # nebula-console  -addr 192.168.8.128 -port 9669 -user user -password password\n2021/07/14 07:07:41 [INFO] connection pool is initialized successfully\n\nWelcome to Nebula Graph!\n\n(user@nebula) [(none)]\u003e show spaces\n+--------------------+\n| Name               |\n+--------------------+\n| \"basketballplayer\" |\n+--------------------+\n| \"shareholding\"     |\n+--------------------+\nGot 2 rows (time spent 3851/4595 us)\n\nWed, 14 Jul 2021 07:07:57 UTC\n\n(user@nebula) [(none)]\u003e use shareholding\nExecution succeeded (time spent 1822/2342 us)\n\nWed, 14 Jul 2021 07:08:02 UTC\n\n(user@nebula) [shareholding]\u003e GO 1 TO 3 STEPS FROM \"c_132\" over * BIDIRECT\n+--------------+-------------------+-----------------+--------------------+\n| role_as._dst | is_branch_of._dst | hold_share._dst | reletive_with._dst |\n+--------------+-------------------+-----------------+--------------------+\n| \"p_2024\"     |                   |                 |                    |\n+--------------+-------------------+-----------------+--------------------+\n| \"p_4000\"     |                   |                 |                    |\n+--------------+-------------------+-----------------+--------------------+\n|              |                   | \"c_245\"         |                    |\n+--------------+-------------------+-----------------+--------------------+\n|              |                   | \"p_1039\"        |                    |\n+--------------+-------------------+-----------------+--------------------+\n|              |                   | \"p_1399\"        |                    |\n+--------------+-------------------+-----------------+--------------------+\n|              |                   | \"p_1767\"        |                    |\n...\n+--------------+-------------------+-----------------+--------------------+\n|              |                   | \"c_132\"         |                    |\n+--------------+-------------------+-----------------+--------------------+\n|              |                   | \"c_245\"         |                    |\n+--------------+-------------------+-----------------+--------------------+\n|              |                   | \"c_25\"          |                    |\n+--------------+-------------------+-----------------+--------------------+\n|              |                   | \"c_649\"         |                    |\n+--------------+-------------------+-----------------+--------------------+\n|              |                   | \"c_753\"         |                    |\n+--------------+-------------------+-----------------+--------------------+\nGot 1519 rows (time spent 12190/14702 us)\n\nWed, 14 Jul 2021 07:08:06 UTC\n\n```\n\n\n\n#### In a Visual Way\n\nOf course, we can also be done in a visual way:\n\nStep 1, login from Nebula Graph Studio, explore with one VID: `c_132`:\n\n![studio_explore_0](./images/studio_explore_0.png)\n\nStep2, click this explored vertex dot, then you can explore from select vertices by selecting:\n\n- Edge Type\n- Direction\n- Steps\n- Query Limit(Optional)\n\n\u003e note, you can click the 👁️ icon to add options to show fields of the graph,\n\n![studio_explore_1](./images/studio_explore_1.png)\n\nStep3, after click Expand, you will see all quried relations with `c_132` the `Chambers LLC`.\n\n![studio_explore_2](./images/studio_explore_2.png)\n\n#### In Gephi Lite:\n\nhttps://github.com/wey-gu/nebula-shareholding-example/assets/1651790/c69df81b-994e-4081-8026-e49744663dd7\n\nSee https://graph-hub.siwei.io/en/latest/datasets/shareholding/\n\n## Thanks to Upstream Projects ❤️\n\n- Python Faker https://github.com/joke2k/faker/\n- pydbgen https://github.com/tirthajyoti/pydbgen\n- Nebula Graph https://github.com/vesoft-inc/nebula\n\n\n\n### Tips:\n\n- You can deploy nebula graph in one line with:\n  - [Nebula-UP](https://siwei.io/nebula-up/), it helps install a nebula graph with Docker\n  - [Nebula-operator-KIND](https://siwei.io/nebula-operator-kind/) , it helps setup all dependencies of Nebula-K8s-Operator including a K8s in Docker, PV Provider and then install a Nebula Graph with Nebula-Operator in K8s.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwey-gu%2Fnebula-shareholding-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwey-gu%2Fnebula-shareholding-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwey-gu%2Fnebula-shareholding-example/lists"}