static private int numOrder ; static private int [] num ; static private void doTarjan (int s, int pere) { numOrder++ ; num[s] = numOrder ; for (List p = succ[s] ; p != null ; p = p.next) { int n = p.val ; if (num[n] == 0) { System.out.println("Arbre : " + s + " -> " + n) ; doTarjan(n, s) ; } else if (num[n] < num[s] && n != pere) { System.out.println("Retour : " + s + " -> " + n) ; } } } static void tarjan(int s) { numOrder = 0 ; num = new int[succ.length] ; doTarjan(s,s) ; } |
// renvoie le numéro du point d'attache private static int doFindArticulation (int s, int pere) { int lowpt ; boolean found = false ; ++numOrder ; lowpt = num[s] = numOrder ; for (List p = succ[s] ; p != null ; p = p.next) { int n = p.val ; if (num[n] == 0) { int lowN = doFindArticulation(n, s) ; lowpt = Math.min(lowN,lowpt) ; if (lowN >= num[s]) { System.out.println("Articulation : " + s) ; } } else if (num[n] < num[s] && n != pere) { lowpt = Math.min(num[n],lowpt) ; } } return lowpt ; } static void findArticulations(int s) { numOrder = 0 ; num = new int[succ.length] ; int nfils = 0 ; numOrder++ ; num[s] = numOrder ; for (List p = succ[s] ; p != null ; p = p.next) { int n = p.val ; if (num[n] == 0) { doFindArticulation(n, s) ; nfils++ ; } } if (nfils > 1) System.out.println("La racine " + s + " est un point d'articulation") ; } |
This document was translated from LATEX by HEVEA and HACHA.