<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?action=history&amp;feed=atom&amp;title=Shortest_path_in_graph</id>
	<title>Shortest path in graph - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?action=history&amp;feed=atom&amp;title=Shortest_path_in_graph"/>
	<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Shortest_path_in_graph&amp;action=history"/>
	<updated>2026-04-15T06:18:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Shortest_path_in_graph&amp;diff=45&amp;oldid=prev</id>
		<title>WikiSysop: Created page with &quot;__NOTOC__ === Description === The program is given as input a file containing connected nodes in a graph and a weight assigned to the edge between the nodes. The program shall answer the questions: Is there a path between two given nodes in the graph? If so, what is the shortest path ?&lt;br&gt; This is useful in a number of situations: Protein interaction, which proteins interact together, thereby discovering f.ex. new pathways. Social networks, who knows who, proving the &quot;si...&quot;</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Shortest_path_in_graph&amp;diff=45&amp;oldid=prev"/>
		<updated>2025-09-26T12:32:28Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__NOTOC__ === Description === The program is given as input a file containing connected nodes in a graph and a weight assigned to the edge between the nodes. The program shall answer the questions: Is there a path between two given nodes in the graph? If so, what is the shortest path ?&amp;lt;br&amp;gt; This is useful in a number of situations: Protein interaction, which proteins interact together, thereby discovering f.ex. new pathways. Social networks, who knows who, proving the &amp;quot;si...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
=== Description ===&lt;br /&gt;
The program is given as input a file containing connected nodes in a graph and a weight assigned to the edge between the nodes. The program shall answer the questions: Is there a path between two given nodes in the graph? If so, what is the shortest path ?&amp;lt;br&amp;gt;&lt;br /&gt;
This is useful in a number of situations: Protein interaction, which proteins interact together, thereby discovering f.ex. new pathways. Social networks, who knows who, proving the &amp;quot;six degrees&amp;quot; theory.&lt;br /&gt;
&lt;br /&gt;
=== Input/output ===&lt;br /&gt;
The program is given a graph file as input on the command line. A graph file is a tab delimited file, that looks like this (social network example):&lt;br /&gt;
&lt;br /&gt;
 Chris Workman     Peter Wad Sackett       1&lt;br /&gt;
 Chris Workman     Mette Voldbye           2&lt;br /&gt;
 Carsten Friis     Sune Frankild           4&lt;br /&gt;
&lt;br /&gt;
Each line contains an edge in the graph, given by the name of the two connected nodes, and a weight. All edges are two-way, i.e. if Chris knows Peter, then Peter knows Chris.&amp;lt;br&amp;gt;&lt;br /&gt;
Having read the file and constructed the internal data structures, that represents the graph the program should ask for two nodes (names in this example) and find the shortest path between them, if any, and print out the result.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Example output&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
No node is named Anders Fjog&amp;lt;br&amp;gt;&lt;br /&gt;
There is no path between Sune Frankild and Mette Voldbye&amp;lt;br&amp;gt;&lt;br /&gt;
Shortest path: Chris Workman -&amp;gt; Peter Wad Sackett, weight 1&amp;lt;br&amp;gt;&lt;br /&gt;
Shortest path: Mette Voldbye -&amp;gt; Chris Workman -&amp;gt; Peter Wad Sackett, weight 3&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Examples of program execution&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
shortest_path.py graphfile.txt&lt;br /&gt;
&lt;br /&gt;
=== Details ===&lt;br /&gt;
If there is more than one path between two nodes, then the shortest path should be selected. The length of the path is determined by the weight of the edge between two nodes. The weights are simply added together, smallest number wins. The program is a general purpose tool.&amp;lt;br&amp;gt;&lt;br /&gt;
The nature of the graphs and thereby the problems that can be solved, are changed by either giving all edges the same weight, or different weights. Even negative weights are possible, making certain edges hugely preferred.&lt;br /&gt;
&lt;br /&gt;
Good resource on the problem: https://en.wikipedia.org/wiki/Shortest_path_problem&amp;lt;br&amp;gt;&lt;br /&gt;
It will be good for inspiration. I recommend implementing Dijkstra&amp;#039;s algorithm or Bellman–Ford algorithm.&lt;br /&gt;
&lt;br /&gt;
Here is a [https://teaching.healthtech.dtu.dk/material/22118/humanPPint.lst list of human protein-protein interactions].&amp;lt;br&amp;gt;&lt;br /&gt;
Your program should detect that COL4A2 &amp;lt;=&amp;gt; Nid2 &amp;lt;=&amp;gt; ITGA5 &amp;lt;=&amp;gt; Vpr &amp;lt;=&amp;gt; IL12A are interacting like this and TPD52 and RasGRP3 do not interact. Note that COL4A2 and IL12A can interact in other equally short ways.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
</feed>