Mathematica Mathematica, Matrices and Graph Theory

AI Thread Summary
The discussion revolves around issues encountered when calculating the edge weights of a minimum spanning tree (MST) in Mathematica. A user imported a 30 x 30 matrix and created a graph, but when attempting to retrieve the edge weights of the MST, they received a value of 1 for each edge weight instead of the expected values. Another participant sought clarification on the term "edgeweight," implying a potential misunderstanding of the graph's weighted nature. The original poster expressed frustration over the perceived oddity of their request for MST weights. Ultimately, a workaround was suggested: using the Hadamard product of the unweighted adjacency matrix with the original weight matrix to obtain the correct weighted adjacency matrix for the MST.
Moonshine
Messages
31
Reaction score
0
Hello

I imported a 30 X 30 matrix into Mathematica. I made a graph out of this and then found the minimum spanning tree. Next, I printed off a list of the edges. I included the edgeweight option to get the associated weights listed next to each edge. My goal was to ultimately sum these weights.

The problem is, it returns 1 for every edgeweight of the minimum spanning tree. When I print the edgeweights for the graph from which the minimum spanning tree was made, the correct edgeweights are returned.

Any ideas what I'm doing wrong?
 
Physics news on Phys.org
Hi,
really sorry for the bump, I'm having the same problem. Any help would be greatly appreciated.
 
Would you clarify what you mean by "edgeweight". Do you mean this in the usual sense... I.e. A weighted graph? Also this must clearly be a homework assignment, right? Because both of you have the same weird request?
 
How exactly is this a weird request? I just want the weights of a minimum spanning tree.

Anyway I've found a way around this: to get the weighted adjacency matrix of the MST, I just took the pointwise (Hadamard) product of the unweighted matrix with the original matrix of weights.
 
Back
Top