xlm.tasks.star
simple_star_graph(degree=3, pathlength=5, vocab_size=20)
Generate a asymmetric star graph.
Adapted from : https://github.com/gregorbachmann/Next-Token-Failures/blob/main/data/graphs.py
Properties
- The source is always the center of the star.
- The goal is always the end of one of the arms of the star.
- No nodes are repeated in the graph. So pathlength * degree + 1 should be greater than or equal to vocab_size otherwise the code will loop indefinitely.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degree
|
int
|
int, number of edges from source (center of the start) to other nodes |
3
|
pathlength
|
int
|
int, length of the path (in terms of number of nodes) |
5
|
vocab_size
|
int
|
int, number of nodes in the graph |
20
|
Returns: path: list, path from source to goal edge_list: list, list of edges in the graph
plot_graph(edge_list, path=None, source=None, goal=None)
Example usage: graph = simple_star_graph(4, 4, 20) plot_graph(graph["edge_list"], graph["path"], graph["source"], graph["goal"])