Skip to main content
deleted 3 characters in body; added 80 characters in body
Source Link
Ernest
  • 41
  • 1
  • 2

Let $G=(V,E)$ be a graph.

$FindPaths(p,f)$ prints all paths which end in $f$ and can be obtained by adding nodes to path $p$. $p$ is for path, $f$ is for final (node).

Def $FindPaths(p,f)$:
Let $l$$x$ be the last node of $p$.
For each edge $(l,v)$$xy$ for some $v$$y$ in $E$
$\ \ \ \ $If $v$$y$ is not in $p$
$\ \ \ \ $$\ \ \ \ $If $v=f$$y=f$
$\ \ \ \ $$\ \ \ \ $$\ \ \ \ $Print $p-v$$p-y$
$\ \ \ \ $$\ \ \ \ $Else
$\ \ \ \ $$\ \ \ \ $$\ \ \ \ $$FindPaths(p-v,f)$$\ \ \ \ $$\ \ \ \ $$\ \ \ \ $$FindPaths(p-y,f)$

If $s$ is the start node and $t$ is the ending node, run $FindPaths(s,t)$.

You can represent path and edges as strings. To check if a node is in a path $p$ you just have to check whether the string contains the character that represents the node. To get the final node of a path use the function to get the last character of a string.

EDIT: My answer is not math research level, but introduction to programming.

Let $G=(V,E)$ be a graph.

$FindPaths(p,f)$ prints all paths which end in $f$ and can be obtained by adding nodes to path $p$. $p$ is for path, $f$ is for final (node).

Def $FindPaths(p,f)$:
Let $l$ be the last node of $p$.
For each edge $(l,v)$ for some $v$ in $E$
$\ \ \ \ $If $v$ is not in $p$
$\ \ \ \ $$\ \ \ \ $If $v=f$
$\ \ \ \ $$\ \ \ \ $$\ \ \ \ $Print $p-v$
$\ \ \ \ $$\ \ \ \ $Else
$\ \ \ \ $$\ \ \ \ $$\ \ \ \ $$FindPaths(p-v,f)$

If $s$ is the start node and $t$ is the ending node, run $FindPaths(s,t)$.

You can represent path and edges as strings. To check if a node is in a path $p$ you just have to check whether the string contains the character that represents the node. To get the final node of a path use the function to get the last character of a string.

Let $G=(V,E)$ be a graph.

$FindPaths(p,f)$ prints all paths which end in $f$ and can be obtained by adding nodes to path $p$. $p$ is for path, $f$ is for final (node).

Def $FindPaths(p,f)$:
Let $x$ be the last node of $p$.
For each edge $xy$ for some $y$ in $E$
$\ \ \ \ $If $y$ is not in $p$
$\ \ \ \ $$\ \ \ \ $If $y=f$
$\ \ \ \ $$\ \ \ \ $$\ \ \ \ $Print $p-y$
$\ \ \ \ $$\ \ \ \ $Else
$\ \ \ \ $$\ \ \ \ $$\ \ \ \ $$FindPaths(p-y,f)$

If $s$ is the start node and $t$ is the ending node, run $FindPaths(s,t)$.

You can represent path and edges as strings. To check if a node is in a path $p$ you just have to check whether the string contains the character that represents the node. To get the final node of a path use the function to get the last character of a string.

EDIT: My answer is not math research level, but introduction to programming.

Source Link
Ernest
  • 41
  • 1
  • 2

Let $G=(V,E)$ be a graph.

$FindPaths(p,f)$ prints all paths which end in $f$ and can be obtained by adding nodes to path $p$. $p$ is for path, $f$ is for final (node).

Def $FindPaths(p,f)$:
Let $l$ be the last node of $p$.
For each edge $(l,v)$ for some $v$ in $E$
$\ \ \ \ $If $v$ is not in $p$
$\ \ \ \ $$\ \ \ \ $If $v=f$
$\ \ \ \ $$\ \ \ \ $$\ \ \ \ $Print $p-v$
$\ \ \ \ $$\ \ \ \ $Else
$\ \ \ \ $$\ \ \ \ $$\ \ \ \ $$FindPaths(p-v,f)$

If $s$ is the start node and $t$ is the ending node, run $FindPaths(s,t)$.

You can represent path and edges as strings. To check if a node is in a path $p$ you just have to check whether the string contains the character that represents the node. To get the final node of a path use the function to get the last character of a string.