Пример #1
0
  protected static ArrayList<Clique> triangulate(MoralGraph graph) {
    // Heuristic: Repeatedly remove a simplicial node and if none exists
    // then remove a node with the smallest size(family)
    ArrayList<Clique> cliques = new ArrayList<Clique>();

    // make a working copy of the graph
    MoralGraph workingGraph = (MoralGraph) graph.clone();

    // While there are more nodes in the working graph
    while (workingGraph.size() > 0) {
      // Find next node to process as a clique
      MoralGraphNode node = processNextNode(workingGraph);

      // create clique
      cliques.add(createClique(node));

      // remove node from graph
      removeNode(workingGraph, node);
    }

    return cliques;
  }