The most important node is node, which when deleted will reduce the graph by 2 or more disjoint subgraphs.
Thus, the key node is a node that is connected to 2 or more subgraphs that are connected only through this important node ..
A possible solution could be this:
Link: Wikipedia: Cycle Detection
Example (in Java):
public class CrucialNode { public static ArrayList<Node> crucialVertices (Graph g) { ArrayList<Node> crucial = new ArrayList<Node> (); for (Node n : g.getV()) if (isCrucial(g,n)) crucial.add(n); return crucial; } public static boolean isCrucial (Graph g, Node n) { Graph h = new Graph(g); h.removeVertex(n); for (Node u : n.getNext()) { for (Node v : n.getNext()) { if (u.equals(v)) continue; if (!h.connected(u,v)) return true; } } return false; } }
source share