Procedural Datasets

polygraph.datasets.ProceduralPlanarGraphDataset

Bases: ProceduralGraphDataset

Procedural version of PlanarGraphDataset.

Graphs are generated by sampling random node positions in the unit square and producing a Delaunay triangulation.

Parameters:
  • split (Literal['train', 'val', 'test']) –

    Split to load.

  • num_graphs (int) –

    Number of graphs to generate for this split.

  • n_nodes (int, default: 64 ) –

    Number of nodes in the graphs.

  • seed (int, default: 42 ) –

    Seed for the random number generator.

  • memmap (bool, default: False ) –

    Whether to use memory mapping for the dataset.

is_valid(graph)

Check if a graph is valid (connected and planar).

polygraph.datasets.ProceduralSBMGraphDataset

Bases: ProceduralGraphDataset

Procedural version of SBMGraphDataset.

Graphs are generated by first sampling the number of communties and then the number of nodes per community. Finally, edges are sampled according to the intra- and inter-community edge probabilities.

Parameters:
  • split (Literal['train', 'val', 'test']) –

    Split to load.

  • num_graphs (int) –

    Number of graphs to generate for this split.

  • seed (int, default: 42 ) –

    Seed for the random number generator.

  • intra_p (float, default: 0.3 ) –

    Intra-community edge probability.

  • inter_p (float, default: 0.005 ) –

    Inter-community edge probability.

  • n_communities (Tuple[int, int], default: (2, 5) ) –

    Range of number of communities in the format (min, max).

  • n_nodes_per_community (Tuple[int, int], default: (20, 40) ) –

    Range of number of nodes per community in the format (min, max).

  • memmap (bool, default: False ) –

    Whether to use memory mapping for the dataset.

is_valid(graph)

Check if a graph is a valid SBM graph.

polygraph.datasets.ProceduralLobsterGraphDataset

Bases: ProceduralGraphDataset

Procedural version of LobsterGraphDataset.

Parameters:
  • split (Literal['train', 'val', 'test']) –

    Split to load.

  • num_graphs (int) –

    Number of graphs to generate for this split.

  • expected_num_nodes (int, default: 80 ) –

    Steers the expected number of nodes in the generated graphs.

  • p1 (float, default: 0.7 ) –

    Probability of adding an edge to the backbone.

  • p2 (float, default: 0.7 ) –

    Probability of adding an edge one level beyond the backbone.

  • min_number_of_nodes (Optional[int], default: 10 ) –

    Minimum number of nodes in the generated graphs.

  • max_number_of_nodes (Optional[int], default: 100 ) –

    Maximum number of nodes in the generated graphs.

  • seed (int, default: 42 ) –

    Seed for the random number generator.

  • memmap (bool, default: False ) –

    Whether to use memory mapping for the dataset.

is_valid(graph)

Check if a graph is a valid lobster graph.