Mathematica, Matrices and Graph Theory

In summary, "edgeweight" refers to the weights associated with edges in a graph, and it seems to be a homework assignment for both parties involved in the conversation. The issue faced is that when printing the edgeweights for the minimum spanning tree, it returns a value of 1 for every weight. A workaround was found by taking the pointwise product of the unweighted matrix with the original weight matrix to obtain the weighted adjacency matrix of the MST.
  • #1
Moonshine
32
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
  • #2
Hi,
really sorry for the bump, I'm having the same problem. Any help would be greatly appreciated.
 
  • #3
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?
 
  • #4
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.
 
  • #5


It is difficult to determine the exact issue without seeing the code you used. However, one possible explanation could be that the minimum spanning tree algorithm in Mathematica may be using a different set of weights than the ones you are expecting. It is also possible that there is an error in the code that is causing the incorrect weights to be returned. I would suggest checking your code and potentially consulting the Mathematica documentation for more information on the minimum spanning tree algorithm. Additionally, it may be helpful to reach out to the Mathematica community for assistance and troubleshooting tips.
 

1. What is Mathematica and how is it used in mathematics?

Mathematica is a software program that is used for mathematical computation, data analysis, and visualization. It is commonly used in fields such as physics, engineering, and finance. Mathematica uses a symbolic language to manipulate mathematical expressions and provides a user-friendly interface for solving complex mathematical problems.

2. What are matrices and how are they used in mathematics?

Matrices are rectangular arrays of numbers or symbols arranged in rows and columns. They are used in mathematics to represent linear transformations, solve systems of linear equations, and perform operations such as addition, subtraction, and multiplication. Matrices are also used in fields such as computer graphics, statistics, and economics.

3. How does graph theory relate to mathematics?

Graph theory is a branch of mathematics that deals with the study of graphs, which are mathematical structures used to model relationships between objects. It is used in a variety of fields, including computer science, engineering, and social sciences. Graph theory helps us understand the properties and behaviors of networks, and has practical applications in areas such as transportation, communication, and social networks.

4. Can Mathematica be used for graph theory?

Yes, Mathematica has built-in functions and algorithms that can be used for graph theory. These include functions for creating graphs, finding shortest paths, and calculating network properties. Mathematica also has a Graph Theory package that provides additional capabilities for analyzing and visualizing graphs.

5. How can matrices be used to represent graphs in Mathematica?

Matrices can be used to represent graphs in Mathematica by using an adjacency matrix. This is a square matrix where the rows and columns represent the vertices of the graph, and the entries represent the presence or absence of edges between vertices. Using an adjacency matrix, we can perform operations on graphs such as finding the shortest path, calculating the degree of a vertex, and determining the connected components of a graph.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
Replies
9
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
Replies
2
Views
696
  • Programming and Computer Science
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top