I'm facing some issues when trying to use the CommunityStructureAssignment
function from the GraphUtilities package in Mathematica 8.
I'd like to output a community structure assignment for my random graph, but it seems the function is unrecognized by Mathematica.
In particular with the following code I'm creating a random weighted graph G
with 10 nodes and 30 edges and I visualize the weighted adjacency matrix:
nNodes = 10;
nEdges = 30;
G = Graph[EdgeList[RandomGraph[{nNodes, nEdges}]], EdgeWeight -> RandomReal[{0.1, 5}, nEdges]];
W = WeightedAdjacencyMatrix[G];
W // MatrixForm
After that, following the documentation of CommunityStructureAssignment
, I'd imagine that feeding the EdgeList
of G
directly to CommunityStructureAssignment
would result in a list but:
CommunityStructureAssignment[EdgeList[G], Weighted -> True]
returns it self:
CommunityStructureAssignment[{1 \[UndirectedEdge] 4,
1 \[UndirectedEdge] 5, 2 \[UndirectedEdge] 4, 2 \[UndirectedEdge] 5,
2 \[UndirectedEdge] 1, 2 \[UndirectedEdge] 3,
3 \[UndirectedEdge] 5, 3 \[UndirectedEdge] 1, 4 \[UndirectedEdge] 5,
4 \[UndirectedEdge] 3}, Weighted -> True]
while the documentation clearly says that:
g = {3 -> 2, 2 -> 1, 1 -> 3, 3 -> 5, 5 -> 6, 6 -> 7, 7 -> 5};
CommunityStructureAssignment[g]
should correctly work.
Now the question is: how can I feed the correct input graph into CommunityStructureAssignment? And also how to include the edge weights into the EdgeList
?
Also I have to say, that once i import the GraphUtilities package, the definition of EdgeList
turns red. Is this because there is a conflict of names?