Example #1
0
  /**
   * A split graph of a split pair with respect of some edge is the union of all split components
   * which don't contain that edge
   *
   * @param splitComponents
   * @param edge
   * @return
   */
  public Graph<V, E> splitGraph(List<SplitComponent<V, E>> splitComponents, E edge) {

    List<Graph<V, E>> allComponentsNotContainingEdge = new ArrayList<Graph<V, E>>();
    for (SplitComponent<V, E> component : splitComponents)
      if (!component.getEdges().contains(edge)) allComponentsNotContainingEdge.add(component);

    GraphOperations<V, E> operations = new GraphOperations<>();
    return operations.union(allComponentsNotContainingEdge);
  }
Example #2
0
  /**
   * A split pair {u,v} is dominated by another split pair {x,y} if
   *
   * @param dominant
   * @param other
   * @param edge
   * @return
   */
  public boolean splitPairIsDominantedBy(
      Graph<V, E> graph, SplitPair<V, E> dominanted, SplitPair<V, E> dominant, E edge) {
    GraphOperations<V, E> operations = new GraphOperations<>();

    Graph<V, E> splitGraph1 = splitGraph(findAllSplitComponents(graph, dominanted), edge);
    Graph<V, E> splitGraph2 = splitGraph(findAllSplitComponents(graph, dominant), edge);

    return operations.isProperSubgraph(splitGraph2, splitGraph1);
  }
Example #3
0
  /**
   * All components should have two vertices in common: split pair vertices and no edges
   *
   * @param components
   * @return
   */
  public boolean testSplitComponents(
      List<SplitComponent<V, E>> components, SplitPair<V, E> splitPair) {
    GraphOperations<V, E> operations = new GraphOperations<>();
    for (int i = 0; i < components.size(); i++)
      for (int j = i + 1; j < components.size(); j++) {
        SplitComponent<V, E> com1 = components.get(i);
        SplitComponent<V, E> com2 = components.get(j);
        List<V> verticesInCommon = operations.verticesInCommon(com1, com2);
        if (!verticesInCommon.contains(splitPair.getU())
            || !verticesInCommon.contains(splitPair.getV())
            || verticesInCommon.size() != 2) return false;
        List<E> edgesInCommon = operations.edgesInCommon(com1, com2);
        if (edgesInCommon.size() > 0) return false;
      }

    return true;
  }