Skip to content

Graph partitioning interface #28

Description

@mtfishman

Currently we have functions:

using NamedGraphs
using ITensors
using ITensorNetworks
using Metis

tn = ITensorNetwork(named_grid((4, 4)); link_space=4)
partition(tn, 2)
subgraphs(tn, nv(tn) ÷ 2)

for partitioning graphs, which output:

julia> partition(tn, 2)
16-element Dictionaries.Dictionary{Tuple{Int64, Int64}, Int64}
 (1, 1) │ 1
 (2, 1) │ 1
 (3, 1) │ 1
 (4, 1) │ 1
 (1, 2) │ 1
 (2, 2) │ 1
 (3, 2) │ 1
 (4, 2) │ 1
 (1, 3) │ 2
 (2, 3) │ 2
 (3, 3) │ 2
 (4, 3) │ 2
 (1, 4) │ 2
 (2, 4) │ 2
 (3, 4) │ 2
 (4, 4) │ 2

julia> subgraphs(tn, nv(tn) ÷ 2)
DataGraph{Int64, Vector{Tuple{Int64, Int64}}, Any, NamedGraph{Int64}, NamedEdge{Int64}} with 2 vertices:
2-element Vector{Int64}:
 1
 2

and 1 edge(s):
1 => 2

with vertex data:
2-element Dictionaries.Dictionary{Int64, Vector{Tuple{Int64, Int64}}}
 1 │ [(1, 1), (2, 1), (3, 1), (4, 1), (1, 2), (2, 2), (3, 2), (4, 2)]
 2 │ [(1, 3), (2, 3), (3, 3), (4, 3), (1, 4), (2, 4), (3, 4), (4, 4)]

and edge data:
0-element Dictionaries.Dictionary{NamedEdge{Int64}, Any}

We should make them consistent so that they both can accept the partition size or the number of partitions. Additionally, their names should give a better indication for what they output.

For example, I could imagine a function:

julia> partition_vertices(tn, 2)
2-element Vector{Vector{Tuple{Int64, Int64}}}:
 [(1, 1), (2, 1), (3, 1), (4, 1), (1, 2), (2, 2), (3, 2), (4, 2)]
 [(1, 3), (2, 3), (3, 3), (4, 3), (1, 4), (2, 4), (3, 4), (4, 4)]

julia> partition_vertices(tn; partition_size=nv(tn) ÷ 2)
2-element Vector{Vector{Tuple{Int64, Int64}}}:
 [(1, 1), (2, 1), (3, 1), (4, 1), (1, 2), (2, 2), (3, 2), (4, 2)]
 [(1, 3), (2, 3), (3, 3), (4, 3), (1, 4), (2, 4), (3, 4), (4, 4)]

Or perhaps partition_vertices should output a DataGraph like subgraphs does right now, which also keeps track of which partitions have connected edges.

@JoeyT1994 curious about your opinion on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions