vstenby commited on
Commit
5db14ec
·
verified ·
1 Parent(s): 0fc86ac

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +124 -64
README.md CHANGED
@@ -1,64 +1,124 @@
1
- ---
2
- license: apache-2.0
3
- configs:
4
- - config_name: default
5
- data_files:
6
- - split: train
7
- path: data/train-*
8
- - split: validation
9
- path: data/validation-*
10
- - split: test
11
- path: data/test-*
12
- dataset_info:
13
- features:
14
- - name: algorithm
15
- dtype: string
16
- - name: edge_list
17
- dtype: string
18
- - name: node_count
19
- dtype: int64
20
- - name: edge_count
21
- dtype: int64
22
- - name: node_degree_node
23
- dtype: int64
24
- - name: node_degree
25
- dtype: int64
26
- - name: edge_existence_src
27
- dtype: int64
28
- - name: edge_existence_dst
29
- dtype: int64
30
- - name: edge_existence
31
- dtype: bool
32
- - name: cycle_check
33
- dtype: bool
34
- - name: triangle_count
35
- dtype: int64
36
- - name: connected_nodes_node
37
- dtype: int64
38
- - name: connected_nodes
39
- dtype: string
40
- - name: reachability_src
41
- dtype: int64
42
- - name: reachability_dst
43
- dtype: int64
44
- - name: reachability
45
- dtype: bool
46
- - name: shortest_path_src
47
- dtype: int64
48
- - name: shortest_path_dst
49
- dtype: int64
50
- - name: shortest_path
51
- dtype: int64
52
- splits:
53
- - name: train
54
- num_bytes: 6311306
55
- num_examples: 10000
56
- - name: validation
57
- num_bytes: 646652
58
- num_examples: 1000
59
- - name: test
60
- num_bytes: 635077
61
- num_examples: 1000
62
- download_size: 1529568
63
- dataset_size: 7593035
64
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: mit
4
+ size_categories:
5
+ - 10K<n<100K
6
+ task_categories:
7
+ - graph-ml
8
+ tags:
9
+ - graphs
10
+ - synthetic
11
+ - erdos-renyi
12
+ - barabasi-albert
13
+ - watts-strogatz
14
+ - stochastic-block-model
15
+ - complete-graph
16
+ - graph-qa
17
+ ---
18
+
19
+ # Graph Dataset with Task Labels
20
+
21
+ A synthetic graph dataset containing graphs generated using five different algorithms, with pre-computed answers for 9 graph reasoning tasks.
22
+
23
+ ## Dataset Description
24
+
25
+ This dataset contains synthetic graphs represented as edge lists, along with ground-truth answers for various graph reasoning tasks. The graphs are generated using five classical random graph models:
26
+
27
+ - **Erdős–Rényi**: Random graphs where each edge is included independently with probability p
28
+ - **Barabási–Albert**: Scale-free networks generated using preferential attachment
29
+ - **Watts–Strogatz**: Small-world networks with high clustering and short path lengths
30
+ - **Stochastic Block Model**: Community-structured graphs with 2-4 communities, higher edge probability within communities than between
31
+ - **Complete Graph**: Fully connected graphs where every pair of nodes is connected
32
+
33
+ ## Dataset Structure
34
+
35
+ ### Data Fields
36
+
37
+ | Field | Type | Description |
38
+ |-------|------|-------------|
39
+ | `algorithm` | string | Graph generation algorithm: `erdos_renyi`, `barabasi_albert`, `watts_strogatz`, `stochastic_block_model`, or `complete` |
40
+ | `edge_list` | string | Edge list in format `(u, v), (x, y), ...` |
41
+
42
+ #### Task Columns
43
+
44
+ | Task | Fields | Description |
45
+ |------|--------|-------------|
46
+ | **node_count** | `node_count` (int) | Number of nodes in the graph |
47
+ | **edge_count** | `edge_count` (int) | Number of edges in the graph |
48
+ | **node_degree** | `node_degree_node` (int), `node_degree` (int) | Sampled node and its degree |
49
+ | **edge_existence** | `edge_existence_src` (int), `edge_existence_dst` (int), `edge_existence` (bool) | Two sampled nodes and whether an edge exists between them |
50
+ | **cycle_check** | `cycle_check` (bool) | Whether the graph contains a cycle |
51
+ | **triangle_counting** | `triangle_count` (int) | Number of triangles in the graph |
52
+ | **connected_nodes** | `connected_nodes_node` (int), `connected_nodes` (string) | Sampled node and comma-separated list of its neighbors |
53
+ | **reachability** | `reachability_src` (int), `reachability_dst` (int), `reachability` (bool) | Two sampled nodes and whether a path exists between them |
54
+ | **shortest_path** | `shortest_path_src` (int), `shortest_path_dst` (int), `shortest_path` (int) | Two sampled nodes and shortest path length (-1 if no path exists) |
55
+
56
+ ### Data Splits
57
+
58
+ | Split | Number of Examples |
59
+ |-------|-------------------|
60
+ | train | 10000 |
61
+ | validation | 1000 |
62
+ | test | 1000 |
63
+
64
+ ### Graph Statistics
65
+
66
+ - **Node range**: [5, 25]
67
+ - **Algorithms**: Balanced across all five types (cycled)
68
+
69
+ ## Usage
70
+
71
+ ```python
72
+ from datasets import load_dataset
73
+
74
+ dataset = load_dataset("vstenby/random-graphs")
75
+
76
+ # Access a sample
77
+ sample = dataset["train"][0]
78
+ print(f"Algorithm: {sample['algorithm']}")
79
+ print(f"Node count: {sample['node_count']}")
80
+ print(f"Edge count: {sample['edge_count']}")
81
+ print(f"Has cycle: {sample['cycle_check']}")
82
+ print(f"Triangle count: {sample['triangle_count']}")
83
+
84
+ # Node-specific tasks
85
+ print(f"Node {sample['node_degree_node']} has degree {sample['node_degree']}")
86
+ print(f"Node {sample['connected_nodes_node']} is connected to: {sample['connected_nodes']}")
87
+
88
+ # Edge/path tasks
89
+ print(f"Edge between {sample['edge_existence_src']} and {sample['edge_existence_dst']}: {sample['edge_existence']}")
90
+ print(f"Path from {sample['reachability_src']} to {sample['reachability_dst']}: {sample['reachability']}")
91
+ print(f"Shortest path from {sample['shortest_path_src']} to {sample['shortest_path_dst']}: {sample['shortest_path']}")
92
+ ```
93
+
94
+ ### Converting to NetworkX
95
+
96
+ ```python
97
+ import networkx as nx
98
+ import ast
99
+
100
+ def parse_edge_list(edge_list_str):
101
+ """Parse edge list string to list of tuples."""
102
+ if not edge_list_str:
103
+ return []
104
+ edges_str = f"[{edge_list_str}]"
105
+ return ast.literal_eval(edges_str)
106
+
107
+ sample = dataset["train"][0]
108
+ edges = parse_edge_list(sample["edge_list"])
109
+ G = nx.Graph()
110
+ G.add_nodes_from(range(sample["node_count"]))
111
+ G.add_edges_from(edges)
112
+ ```
113
+
114
+ ## Generation Details
115
+
116
+ - **Random seed**: 42 (train), 43 (validation), 44 (test)
117
+ - **Generation method**: Each graph has a random number of nodes uniformly sampled from [5, 25]
118
+ - **Task sampling**: For tasks requiring node/edge sampling (node_degree, edge_existence, connected_nodes, reachability, shortest_path), nodes are sampled uniformly at random
119
+
120
+ ## License
121
+
122
+ MIT License
123
+
124
+ MIT License