1 25 package classycle.graph; 26 27 import java.util.HashMap ; 28 import java.util.Map ; 29 30 35 public class StrongComponentAnalyser 36 { 37 private final AtomicVertex[] _graph; 38 private StrongComponent[] _components; 39 private HashMap _layerMap; 40 41 44 public StrongComponentAnalyser(AtomicVertex[] graph) 45 { 46 _graph = graph; 47 } 49 50 51 public AtomicVertex[] getGraph() 52 { 53 return _graph; 54 } 55 56 57 public StrongComponent[] getCondensedGraph() 58 { 59 if (_components == null) 60 { 61 StrongComponentProcessor processor = new StrongComponentProcessor(true); 62 processor.deepSearchFirst(_graph); 63 _components = processor.getStrongComponents(); 64 } 65 return _components; 66 } 67 68 74 public Map getLayerMap() 75 { 76 if (_layerMap == null) 77 { 78 StrongComponent[] components = getCondensedGraph(); 79 new LongestWalkProcessor().deepSearchFirst(components); 80 _layerMap = new HashMap (); 81 for (int i = 0; i < components.length; i++) 82 { 83 StrongComponent component = components[i]; 84 Integer layer = new Integer (component.getLongestWalk()); 85 for (int j = 0, n = component.getNumberOfVertices(); j < n; j++) 86 { 87 _layerMap.put(component.getVertex(j), layer); 88 } 89 } 90 } 91 return _layerMap; 92 } 93 94 } 95 | Popular Tags |