Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/algorithms/ArticulationPointSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default class ArticulationPointSearch {
node.articulationPoint = true;
} else if (node.visitedFrom !== null && child.lowLink >= node.visitIndex) {
this.log(` | Node ${node.id} - parent ${node.visitedFrom}`);
this.log(' | Node is not root but one of it\'s children has a back link to an ancestor - it\'s an articulation point!');
this.log(' | Node is not root but one of its children has a back link to an ancestor - it\'s an articulation point!');
node.articulationPoint = true;
}
});
Expand All @@ -153,4 +153,4 @@ export default class ArticulationPointSearch {
}));
});
}
}
}
18 changes: 9 additions & 9 deletions client/blog/references.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React from 'react';
import ShareButtons from '../components/ShareButtons';

export default (<div>
<p>The real world uses of testing whether a graph is bipartite, but it is a good introduction to the topic of
<a href="https://en.wikipedia.org/wiki/Graph_coloring"> Graph Coloring</a> which is an interesting area of study.</p>
<p>Testing whether a graph is bipartite is a good introduction to the topic of
<a href="https://en.wikipedia.org/wiki/Graph_coloring"> Graph Coloring</a>, which is an interesting area of study.</p>

<h4><a name='bp-pseudocode'>Pseudocode</a></h4>
<p>This algorithm, because it is an extension of BFS, uses a queue to maintain which node to visit next. For each
node it assigns a color based upon the colour(s) assigned to it's parents. Once all nodes have been assigned a color
if we end with using 2 colours, then the graph is bipartite and its nodes can be seperated into two disjoint sets.</p>
node it assigns a color based upon the colour(s) assigned to its parents. Once all nodes have been assigned a color
if we end with using 2 colours, then the graph is bipartite and its nodes can be separated into two disjoint sets.</p>
<code>
function <strong>bipartiteness</strong>( graph )<br/>
&nbsp;&nbsp;queue = new Queue()<br/>
Expand Down Expand Up @@ -65,20 +65,20 @@ export default (<div>

<ul>
<li>Visual - visually show the steps of the algorithm and how it traverses the graph</li>
<li>Interactive - user can easily, and intuitively draw their own graphs and trees and run an algorithm
<li>Interactive - user can easily and intuitively draw their own graphs and trees and run an algorithm
against it</li>
<li>Examples - Access to pre-defined graphs relevant to each algorithm</li>
<li>Running Commentary - Display the output of the algorithm at it runs</li>
<li>Running Commentary - Display the output of the algorithm as it runs</li>
<li>Minimal - users can just click run to see the algorithms run and their output</li>
</ul>

<p>This blog marks the beginning. I've decided to focus on the topic of graph search algorithms here. The hope is
that anyone that is struggling with these algorithms and their applications can gain a better understanding
through running the algorithm and its variations with their own graphs and trees. </p>
through running the algorithm and its variations with their own graphs and trees.</p>

<p>By enabling readers to test out an algorithm with their own graph/tree structures I believe the reader can
learn and grok the concepts more efficiently. In many ways this reflects the intentions
of <a href="https://www.workshape.io">Workshape</a>, in so far as, we try to limit the dependence of words when
of <a href="https://www.workshape.io">Workshape</a>, insofar as we try to limit the dependence of words when
transferring information in order to minimise ambiguity!</p>

<p>It must be said that there are already some great resources out there for teaching people about these types of complex subject
Expand Down Expand Up @@ -122,4 +122,4 @@ export default (<div>
</div>

<ShareButtons/>
</div>);
</div>);
4 changes: 2 additions & 2 deletions client/blog/section2.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default (<div>
<p>When it comes to algorithms <a href="https://en.wikipedia.org/wiki/Depth-first_search">Depth First Search
(DFS)</a> is one of the first things students will be taught at university and it is a gateway for many other important
topics in Computer Science. It is an algorithm for searching or traversing Graph and Tree data structures just like
it's sibling <a href="https://en.wikipedia.org/wiki/Breadth-first_search">Breadth First Search (BFS)</a>.</p>
its sibling <a href="https://en.wikipedia.org/wiki/Breadth-first_search">Breadth First Search (BFS)</a>.</p>

<p className='instruction'>If you run the visualisation below you can see how it works - you can run it on example graphs, or alternatively
draw your own - add nodes by clicking on the canvas below and add edges by dragging from one node to another.</p>
</div>);
</div>);
17 changes: 8 additions & 9 deletions client/blog/section5.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export default (<div>
</ul>
<h4><a name='tscc-pseudocode'>Pseudocode</a></h4>
<p>This algorithm builds upon DFS using a stack and recursion to explore a pathway until it finds a leaf node or
a node already visisted. Unlike DFS though this algorithm does not take a start point, instead it ensures all
a node already visisted. Unlike DFS this algorithm does not take a start point, instead it ensures all
nodes are visited by instigating search on all nodes. At the end of each search cycle if the value of
node.visitIndex is the same as node.lowLink then it creates a new SCC and iteratively pops from the stack and adds
these nodes to the SCC too until it reaches itself again.</p>
these nodes to the new SCC until it reaches itself again.</p>

<code>
function <strong>tarjan-scc</strong>( graph )<br/>
Expand Down Expand Up @@ -56,17 +56,16 @@ export default (<div>
<h3><a name='bc'>Identifying if a Graph is Biconnected</a></h3>
<p>A graph is <a href="https://en.wikipedia.org/wiki/Biconnected_component">biconnected</a> if any node can be
removed and yet the graph remains connected (all nodes can still be reached from all other nodes). The key to
identifying is a graph is biconnected or not, is by searching for the presence of articulation points, or cut
vertices. These are points, that if removed from a graph results in an increase in the number of connected components
within a graph and basically means that without their presence all remaining nodes would not be reachable from one
another.</p>
identifying is a graph is biconnected, is by searching for the presence of articulation points, or cut
vertices. These are points that, if removed from a graph, would cause an increase to the number of connected components
within a graph. Without their presence all remaining nodes would not be reachable from one another.</p>

<p>The most basic way to search for articulation points in a graph is to take a brute force approach and play out
all scenerios. Each node is removed from the graph and we then see if remaining nodes are all connected, if they
all scenarios. Each node is removed from the graph and we then see if remaining nodes are all connected, if they
are not then the node that was removed is an articulation point. We place the removed node back in and then repeat
the process for all remaining nodes.</p>

<p>Whilst this approach will works its time complexity is relatively inefficient at O(N^2). There is an
alternative though that is an extension of DFS that's time complexity is O(N). This algorithm is demonstrated
alternative though that is an extension of DFS that has a time complexity of O(N). This algorithm is demonstrated
in the visualisation below.</p>
</div>);
</div>);
8 changes: 4 additions & 4 deletions client/blog/section6.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ export default (<div>
in an unweighted graph. You can see this behaviour by running the BFS example. In this blog we'll explore one
other application of BFS, using it to test if a graph is bipartite or not.</p>

<h3><a name='bp'>Identifying is a Graph is Bipartite</a></h3>
<h3><a name='bp'>Identifying if a Graph is Bipartite</a></h3>
<p>A graph is bipartite if its nodes can be put into two disjoint sets such that every node in the first set
connects to one or more in the second. If you check out the visualisation below you can see a variation of BFS
that has been applied to see if a graph can be broken into these two disjoint sets. When a node is visited it is
coloured according the colour assigned to its parents:
</p>
<ul>
<li>it it has no parents, it'll be set to color 1</li>
<li>if all it's parents have the same color, it will be set to the alternate of that color</li>
<li>if it's parents have differing colors, it will be set a new color</li>
<li>if all its parents have the same color, it will be set to the alternate of that color</li>
<li>if its parents have differing colors, it will be set a new color</li>
</ul>

<p>At the end of the process if only 2 colors are used then the graph is bipartite.</p>
</div>);
</div>);