Bridges in a connected graph

Def: Bridge is an edge, when removed, will disconnect the graph (or increase the number of connected components by 1). One observation regarding bridges in graph; none of the edges that belong to a loop can be a bridge. So in a graph such as A–B–C–A, removing any of the edge A–B, B–C and C–A … Read more

Algorithm to find lowest common ancestor in directed acyclic graph?

Den Roman’s link (Archived version) seems promising, but it seemed a little bit complicated to me, so I tried another approach. Here is a simple algorithm I used: Let say you want to compute LCA(x,y) with x and y two nodes. Each node must have a value color and count, resp. initialized to white and … Read more

Dijkstra vs. Floyd-Warshall: Finding optimal route on all node pairs

As others have pointed out, Floyd-Warshall runs in time O(n3) and running a Dijkstra’s search from each node to each other node, assuming you’re using a Fibonacci heap to back your Dijkstra’s implementation, takes O(mn + n2 log n). However, you cannot always safely run Dijkstra’s on an arbitrary graph because Dijkstra’s algorithm does not … Read more

Explanation of Algorithm for finding articulation points or cut vertices of a graph

Finding articulation vertices is an application of DFS. In a nutshell, Apply DFS on a graph. Get the DFS tree. A node which is visited earlier is a “parent” of those nodes which are reached by it and visited later. If any child of a node does not have a path to any of the … Read more

Set minimum step size in chart js

If you don’t want to show point value (e.g. 0.5) labels you could write a callback function to filter the point value labels instead of using stepSize. Like this: ticks: { min: 0, // it is for ignoring negative step. beginAtZero: true, callback: function(value, index, values) { if (Math.floor(value) === value) { return value; } … Read more

Finding a minimum spanning tree on a directed graph

The equivalent of a minimum spanning tree in a directed graph is called an optimum branching or a minimum-cost arborescence. The classical algorithm for solving this problem is the Chu-Liu/Edmonds algorithm. There have been several optimized implementations of this algorithm over the years using better data structures; the best one that I know of uses … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)