0
|
3289 Views
|
3 Replies
|
5 Total Likes
View groups...
Share
GROUPS:

# How can I extract individual graph partitions as graphs?

Posted 10 years ago
 After having applied the function FindGraphPartition to an arbitary graph with weighted vertices, how can I go about making graphs of the partitions? e.g. If I cut the original graph into two parts, then how can I make two graphs (with properties preserved)?
3 Replies
Sort By:
Posted 10 years ago
 Play the movie backwards? In:= g1 = Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1, 2 \[UndirectedEdge] 4, 4 \[UndirectedEdge] 5, 5 \UndirectedEdge] 6, 6 \[UndirectedEdge] 4}, VertexWeight -> {5, 7, 7, 2, 1, 5}]; p = FindGraphPartition[g1]; g4 = VertexDelete[g1, First[p]]; g5 = VertexDelete[g1, Last[p]]; FullForm[g4] Out//FullForm=Graph[{4 \[UndirectedEdge] 5, 5 \UndirectedEdge] 6, 6 \[UndirectedEdge] 4}, VertexWeight -> {2, 1, 5}]; 
Posted 10 years ago
 Thank you for the reply! The code doesn't preserve vertex weights if you add them. The following will give unweighted subgraphs: g1 = Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1, 2 \[UndirectedEdge] 4, 4 \[UndirectedEdge] 5, 5 \[UndirectedEdge] 6, 6 \[UndirectedEdge] 4}, VertexWeight -> {5, 7, 7, 2, 1, 5}]; p = FindGraphPartition[g1]; g2 = Subgraph[g1, First[p]]; g3 = Subgraph[g1, Last[p]]; I will continue toying with this. I thought that this link would solve the problem, but that is not the case here. Thanks again!
Posted 10 years ago
 Can you adapt this? And does it preserve all your properties? In:= g1 = Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1, 2 \[UndirectedEdge] 4, 4 \[UndirectedEdge] 5, 5 \[UndirectedEdge] 6, 6 \[UndirectedEdge] 4}]; p = FindGraphPartition[g] Out= {{4, 5, 6}, {1, 2, 3}} In:= g2 = Subgraph[g1, First[p]]; g3 = Subgraph[g1, Last[p]];