Datasets:
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,64 +1,124 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 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
|