Java 类com.intellij.util.graph.GraphAlgorithms 实例源码

项目:intellij-ce-playground    文件:CyclicDependenciesBuilder.java   
public HashMap<PsiPackage, Set<List<PsiPackage>>> getCycles(Collection<PsiPackage> packages) {
  if (myGraph == null){
    myGraph = buildGraph();
  }
  final HashMap<PsiPackage, Set<List<PsiPackage>>> result = new HashMap<PsiPackage, Set<List<PsiPackage>>>();
  for (Iterator<PsiPackage> iterator = packages.iterator(); iterator.hasNext();) {
    PsiPackage psiPackage = iterator.next();
      Set<List<PsiPackage>> paths2Pack = result.get(psiPackage);
      if (paths2Pack == null) {
        paths2Pack = new HashSet<List<PsiPackage>>();
        result.put(psiPackage, paths2Pack);
      }
      paths2Pack.addAll(GraphAlgorithms.getInstance().findCycles(myGraph, psiPackage));
  }
  return result;
}
项目:intellij-ce-playground    文件:ModulesDependenciesPanel.java   
private void buildRightTree(Module module){
  final DefaultMutableTreeNode root = (DefaultMutableTreeNode)myRightTreeModel.getRoot();
  root.removeAllChildren();
  final Set<List<Module>> cycles = GraphAlgorithms.getInstance().findCycles(myModulesGraph, module);
  int index = 1;
  for (List<Module> modules : cycles) {
    final DefaultMutableTreeNode cycle = new DefaultMutableTreeNode(
      AnalysisScopeBundle.message("module.dependencies.cycle.node.text", Integer.toString(index++).toUpperCase()));
    root.add(cycle);
    cycle.add(new DefaultMutableTreeNode(new MyUserObject(false, module)));
    for (Module moduleInCycle : modules) {
      cycle.add(new DefaultMutableTreeNode(new MyUserObject(false, moduleInCycle)));
    }
  }
  ((DefaultTreeModel)myRightTree.getModel()).reload();
  TreeUtil.expandAll(myRightTree);
}
项目:tools-idea    文件:CyclicDependenciesBuilder.java   
public HashMap<PsiPackage, Set<List<PsiPackage>>> getCycles(Collection<PsiPackage> packages) {
  if (myGraph == null){
    myGraph = buildGraph();
  }
  final HashMap<PsiPackage, Set<List<PsiPackage>>> result = new HashMap<PsiPackage, Set<List<PsiPackage>>>();
  for (Iterator<PsiPackage> iterator = packages.iterator(); iterator.hasNext();) {
    PsiPackage psiPackage = iterator.next();
      Set<List<PsiPackage>> paths2Pack = result.get(psiPackage);
      if (paths2Pack == null) {
        paths2Pack = new HashSet<List<PsiPackage>>();
        result.put(psiPackage, paths2Pack);
      }
      paths2Pack.addAll(GraphAlgorithms.getInstance().findCycles(myGraph, psiPackage));
  }
  return result;
}
项目:tools-idea    文件:ModulesDependenciesPanel.java   
private void buildRightTree(Module module){
  final DefaultMutableTreeNode root = (DefaultMutableTreeNode)myRightTreeModel.getRoot();
  root.removeAllChildren();
  final Set<List<Module>> cycles = GraphAlgorithms.getInstance().findCycles(myModulesGraph, module);
  int index = 1;
  for (List<Module> modules : cycles) {
    final DefaultMutableTreeNode cycle = new DefaultMutableTreeNode(
      AnalysisScopeBundle.message("module.dependencies.cycle.node.text", Integer.toString(index++).toUpperCase()));
    root.add(cycle);
    cycle.add(new DefaultMutableTreeNode(new MyUserObject(false, module)));
    for (Module moduleInCycle : modules) {
      cycle.add(new DefaultMutableTreeNode(new MyUserObject(false, moduleInCycle)));
    }
  }
  ((DefaultTreeModel)myRightTree.getModel()).reload();
  TreeUtil.expandAll(myRightTree);
}
项目:consulo    文件:ModulesDependenciesPanel.java   
private void buildRightTree(Module module){
  final DefaultMutableTreeNode root = (DefaultMutableTreeNode)myRightTreeModel.getRoot();
  root.removeAllChildren();
  final Set<List<Module>> cycles = GraphAlgorithms.getInstance().findCycles(myModulesGraph, module);
  int index = 1;
  for (List<Module> modules : cycles) {
    final DefaultMutableTreeNode cycle = new DefaultMutableTreeNode(
      AnalysisScopeBundle.message("module.dependencies.cycle.node.text", Integer.toString(index++).toUpperCase()));
    root.add(cycle);
    cycle.add(new DefaultMutableTreeNode(new MyUserObject(false, module)));
    for (Module moduleInCycle : modules) {
      cycle.add(new DefaultMutableTreeNode(new MyUserObject(false, moduleInCycle)));
    }
  }
  ((DefaultTreeModel)myRightTree.getModel()).reload();
  TreeUtil.expandAll(myRightTree);
}
项目:consulo-java    文件:CyclicDependenciesBuilder.java   
public HashMap<PsiJavaPackage, Set<List<PsiJavaPackage>>> getCycles(Collection<PsiJavaPackage> packages) {
  if (myGraph == null){
    myGraph = buildGraph();
  }
  final HashMap<PsiJavaPackage, Set<List<PsiJavaPackage>>> result = new HashMap<PsiJavaPackage, Set<List<PsiJavaPackage>>>();
  for (Iterator<PsiJavaPackage> iterator = packages.iterator(); iterator.hasNext();) {
    PsiJavaPackage psiPackage = iterator.next();
      Set<List<PsiJavaPackage>> paths2Pack = result.get(psiPackage);
      if (paths2Pack == null) {
        paths2Pack = new HashSet<List<PsiJavaPackage>>();
        result.put(psiPackage, paths2Pack);
      }
      paths2Pack.addAll(GraphAlgorithms.getInstance().findCycles(myGraph, psiPackage));
  }
  return result;
}
项目:intellij-ce-playground    文件:ModulesDependenciesPanel.java   
private void initLeftTreeModel(){
  final DefaultMutableTreeNode root = (DefaultMutableTreeNode)myLeftTreeModel.getRoot();
  root.removeAllChildren();
  myModulesGraph = buildGraph();
  setSplitterProportion();
  ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
      final Map<Module, Boolean> inCycle = new HashMap<Module, Boolean>();
      for (Module module : myModules) {
        if (progressIndicator != null) {
          if (progressIndicator.isCanceled()) return;
          progressIndicator.setText(AnalysisScopeBundle.message("update.module.tree.progress.text", module.getName()));
        }
        if (!module.isDisposed()) {
          Boolean isInCycle = inCycle.get(module);
          if (isInCycle == null) {
            isInCycle = !GraphAlgorithms.getInstance().findCycles(myModulesGraph, module).isEmpty();
            inCycle.put(module, isInCycle);
          }
          final DefaultMutableTreeNode moduleNode = new DefaultMutableTreeNode(new MyUserObject(isInCycle.booleanValue(), module));
          root.add(moduleNode);
          final Iterator<Module> out = myModulesGraph.getOut(module);
          while (out.hasNext()) {
            moduleNode.add(new DefaultMutableTreeNode(new MyUserObject(false, out.next())));
          }
        }
      }
    }
  }, AnalysisScopeBundle.message("update.module.tree.progress.title"), true, myProject);
  sortSubTree(root);
  myLeftTreeModel.reload();
}
项目:intellij-ce-playground    文件:ModulesDependenciesPanel.java   
private Graph<Module> buildGraph() {
  final Graph<Module> graph = ModuleManager.getInstance(myProject).moduleGraph();
  if (isForwardDirection()) {
    return graph;
  }
  else {
    return GraphAlgorithms.getInstance().invertEdgeDirections(graph);
  }
}
项目:tools-idea    文件:ModulesDependenciesPanel.java   
private void initLeftTreeModel(){
  final DefaultMutableTreeNode root = (DefaultMutableTreeNode)myLeftTreeModel.getRoot();
  root.removeAllChildren();
  myModulesGraph = buildGraph();
  setSplitterProportion();
  ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
      final Map<Module, Boolean> inCycle = new HashMap<Module, Boolean>();
      for (Module module : myModules) {
        if (progressIndicator != null) {
          if (progressIndicator.isCanceled()) return;
          progressIndicator.setText(AnalysisScopeBundle.message("update.module.tree.progress.text", module.getName()));
        }
        if (!module.isDisposed()) {
          Boolean isInCycle = inCycle.get(module);
          if (isInCycle == null) {
            isInCycle = !GraphAlgorithms.getInstance().findCycles(myModulesGraph, module).isEmpty();
            inCycle.put(module, isInCycle);
          }
          final DefaultMutableTreeNode moduleNode = new DefaultMutableTreeNode(new MyUserObject(isInCycle.booleanValue(), module));
          root.add(moduleNode);
          final Iterator<Module> out = myModulesGraph.getOut(module);
          while (out.hasNext()) {
            moduleNode.add(new DefaultMutableTreeNode(new MyUserObject(false, out.next())));
          }
        }
      }
    }
  }, AnalysisScopeBundle.message("update.module.tree.progress.title"), true, myProject);
  sortSubTree(root);
  myLeftTreeModel.reload();
}
项目:tools-idea    文件:ModulesDependenciesPanel.java   
private Graph<Module> buildGraph() {
  final Graph<Module> graph = ModuleManager.getInstance(myProject).moduleGraph();
  if (isForwardDirection()) {
    return graph;
  }
  else {
    return GraphAlgorithms.getInstance().invertEdgeDirections(graph);
  }
}
项目:consulo    文件:ModulesDependenciesPanel.java   
private void initLeftTreeModel(){
  final DefaultMutableTreeNode root = (DefaultMutableTreeNode)myLeftTreeModel.getRoot();
  root.removeAllChildren();
  myModulesGraph = buildGraph();
  setSplitterProportion();
  ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
      final Map<Module, Boolean> inCycle = new HashMap<Module, Boolean>();
      for (Module module : myModules) {
        if (progressIndicator != null) {
          if (progressIndicator.isCanceled()) return;
          progressIndicator.setText(AnalysisScopeBundle.message("update.module.tree.progress.text", module.getName()));
        }
        if (!module.isDisposed()) {
          Boolean isInCycle = inCycle.get(module);
          if (isInCycle == null) {
            isInCycle = !GraphAlgorithms.getInstance().findCycles(myModulesGraph, module).isEmpty();
            inCycle.put(module, isInCycle);
          }
          final DefaultMutableTreeNode moduleNode = new DefaultMutableTreeNode(new MyUserObject(isInCycle.booleanValue(), module));
          root.add(moduleNode);
          final Iterator<Module> out = myModulesGraph.getOut(module);
          while (out.hasNext()) {
            moduleNode.add(new DefaultMutableTreeNode(new MyUserObject(false, out.next())));
          }
        }
      }
    }
  }, AnalysisScopeBundle.message("update.module.tree.progress.title"), true, myProject);
  sortSubTree(root);
  myLeftTreeModel.reload();
}
项目:consulo    文件:ModulesDependenciesPanel.java   
private Graph<Module> buildGraph() {
  final Graph<Module> graph = ModuleManager.getInstance(myProject).moduleGraph();
  if (isForwardDirection()) {
    return graph;
  }
  else {
    return GraphAlgorithms.getInstance().invertEdgeDirections(graph);
  }
}