Closed JoeyT1994 closed 9 months ago
Attention: 110 lines
in your changes are missing coverage. Please review.
Comparison is base (
1b356a9
) 82.86% compared to head (30dfeb0
) 78.09%.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@JoeyT1994 could you remind me of the status of this? Is the only thing remaining to change the code organization of insert_vertex!
and related functions?
Yeah I believe that is the case! And I just re-organised it so that add_vertex!
is required for the core interface of an abstractgraph
I think after addressing the last few comments I left this should be good to go.
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 aNamedGraph
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.