This is a homework problem I'm really struggling with. I'm supposed to program the shortest path problem in Mathematica. There are 100 nodes, each node has corresponding distances to 2-3 more nodes. At first I'm supposed to program a module that takes in the graph data, then builds a distance matrix.

An example of the graph data looks like this

node0, node1 0.04, node8 11.11, node14 72.21

node1, node46 1247.25, node6 20.59, node13 64.94

node2, node66 54.18, node31 166.80, node45 1561.45

node3, node20 133.65, node6 2.06, node11 42.43

Where the first node is the initial node and the next few nodes with numbers next to them are the distances.

How do I go about doing this?

Thank you for your help!

  • 4
    $\begingroup$ Possible duplicate of 264032 and perhaps 274695. This is a popular homework question. $\endgroup$
    – Syed
    Oct 25, 2022 at 12:49
  • 3
    $\begingroup$ I’m voting to close this question because this is not a homework help site, but a curated Q&A site about Wolfram Language programming that require that users show a minimum amount of knowledge and due diligence (How to Ask). Furthermore, the question is a duplicate. The OP should edit the question to avoid closure by explaining how is this question both different from previous similar questions and on-topic (help center). $\endgroup$
    – rhermans
    Oct 25, 2022 at 14:38
  • 1
    $\begingroup$ The community expects the following from you: ❌: A clear description of an on-topic problem or goal. ❌: A minimal working Wolfram Language code example, formatted, easy to copy&paste, in Raw InputForm. ❌. An example of what you expect as output. ❌. Some proof of minimal Mathematica knowledge. ❌. Minimum due diligence: Share how you have searched the site and documentation, your attempts and reasons to believe an answer exists. $\endgroup$
    – rhermans
    Oct 25, 2022 at 14:39


Browse other questions tagged or ask your own question.