-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partitioned graphs #44
Conversation
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #44 +/- ##
==========================================
- Coverage 82.86% 78.09% -4.78%
==========================================
Files 22 31 +9
Lines 934 1178 +244
==========================================
+ Hits 774 920 +146
- Misses 160 258 +98 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Matt Fishman <[email protected]>
Co-authored-by: Matt Fishman <[email protected]>
Co-authored-by: Matt Fishman <[email protected]>
Co-authored-by: Matt Fishman <[email protected]>
Co-authored-by: Matt Fishman <[email protected]>
@JoeyT1994 could you remind me of the status of this? Is the only thing remaining to change the code organization of |
Yeah I believe that is the case! And I just re-organised it so that |
I think after addressing the last few comments I left this should be good to go. |
Co-authored-by: Matt Fishman <[email protected]>
Co-authored-by: Matt Fishman <[email protected]>
Co-authored-by: Matt Fishman <[email protected]>
Great! I believe I have resolved the above. |
Looks good, thanks! Interested to see how this works out in the BP code. |
This PR adds support for partitioned graphs (see https://en.wikipedia.org/wiki/Graph_partition and the relevant issue #41)
Specifically an
AbstractPartitionedGraph pg
is a structure which contains:g
(can be accessed viagraph(pg)
)g_partitioned
(can be accessed viapartitioned_graph(pg)
)pv
ofg_partitioned
to the corresponding set of vertices ing
. This information can be accessed viavertices(pg, pv)
.v
ing
to its corresponding vertex ing_partitioned
. This can be accessed withpartition_vertex(pg, v)
As the
AbstractPartitionedGraph
is a subtype of theAbstractNamedGraph
,NamedGraphs
functions immediately can be applied to it. Most functions will simply forward to the underlying graphg
, i.e.is_tree(pg) = is_tree(graph(g))
.However, for functions which actually modify the graph or return a
NamedGraph
type we modify the wholepartitioned_graph
.E.g.
rem_vertex!(pg, v)
will removevertex
fromgraph(pg)
and also modifypartitioned_graph(pg)
and the corresponding vertex maps appropriately.We also introduce the
AbstractPartitionVertex
andAbstractPartitionEdge
type to overload a function likerem_vertex
so thatrem_vertex!(pg, pv::AbstractPartitionVertex)
exists and will removepv
frompartitioned_graph(pg)
and then updategraph(pg)
and the relevant maps correspondingly.This PR also introduces the concrete
PartitionedGraph
type which is structured explicitly as:and operates as expected.
Some example code that can now be written with this PR is:
which partitions the grid by its rows resulting in `pg.pg.partitioned_graph' being a 5-site path graph.
Extensive testing is included in
tests/test_partitionedgraph.jl
and an example is included inexamples/partitioning.jl
. The partitioning librariesKaHyPar.jl
andMetis.jl
can be called to build aPartitionedGraph
from aNamedGraph
g
based on specifying some parameter like the number of partitions and minimising some cost function like the number of edges between partitions. This is the default cost function.E.g.
PartitionedGraph(g; npartitions, backend = "KaHyPar")
will construct aPartitionedGraph
withnpartitions
and attempt to partition in such a way as to minimise the number of edges between partitions.Lots of the code here supercedes the code in
src/partition.jl
ofITensorNetworks.jl
and thus that will be removed in a near term PR.