Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.jbpt.algo.tree.tctree;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import org.jbpt.graph.abs.AbstractTree;
import org.jbpt.graph.abs.IEdge;
import org.jbpt.graph.abs.IGraph;
import org.jbpt.hypergraph.abs.IVertex;
/**
* This class takes a biconnected graph and decomposes it into the tree of the triconnected components.
*
* NOTE THAT GIVEN GRAPH MUST BE BICONNECTED; OTHERWISE RESULT IS UNEXPECTED.
*
* Every triconnected component is either of a trivial, or POLYGON, or BOND, or RIGID type ({@link TCType}).
* Note that every edge is a trivial component, but is not explicitly computed by this class.
* This implementation is an adaption of the algorithm implemented by Martin Mader.
* The general process of this decomposition is described in his master's thesis.
*
* For more information on the algorithm please refer to:
* Carsten Gutwenger and Petra Mutzel: A Linear Time Implementation of SPQR-Trees. Graph Drawing 2000: 77-90.
*
* @see {@link BiconnectivityCheck} for testing graph biconnectivity.
* @see {@link TCType} provides enumeration for types of triconnected components.
*
* @param Edge template.
* @param Vertex template.
*
* @author Martin Mader
* @author Artem Polyvyanyy
* @author Christian Wiggert
*
* @assumption Given graph is biconnected.
*/
public class TCTree, V extends IVertex> extends AbstractTree> {
// Original graph to decompose
protected IGraph graph = null;
// Edge of the original graph to use as a back edge
protected E backEdge = null;
// Maps internal edges used for technical purpose to original graph edges
private Map e2o = new HashMap();
/**
* Constructor.
*
* @param graph A graph to decompose.
*/
public TCTree(IGraph graph) {
if (graph==null) return;
if (graph.getEdges().isEmpty()) return;
this.graph = graph;
this.backEdge = graph.getEdges().iterator().next();
this.construct();
}
/**
* Constructor.
*
* @param graph A graph to decompose.
* @param backEdge An edge of the graph to use as a back edge. A triconnected component that contains the edge will become the root of the tree.
*/
public TCTree(IGraph graph, E backEdge) {
if (graph==null) return;
if (!graph.contains(backEdge)) return;
this.graph = graph;
this.backEdge = backEdge;
this.construct();
}
/**
* Constructs the tree of the triconnected components.
*/
protected void construct() {
Vector> components = new Vector>();
EdgeMap virtualEdgeMap = this.createEdgeMap(this.graph);
virtualEdgeMap.initialiseWithFalse();
virtualEdgeMap.put(backEdge,true);
EdgeMap assignedVirtEdgeMap = this.createEdgeMap(this.graph);
EdgeMap isHiddenMap = this.createEdgeMap(this.graph);
isHiddenMap.initialiseWithFalse();
MetaInfoContainer meta = new MetaInfoContainer();
meta.setMetaInfo(MetaInfo.VIRTUAL_EDGES, virtualEdgeMap);
meta.setMetaInfo(MetaInfo.ASSIGNED_VIRTUAL_EDGES, assignedVirtEdgeMap);
meta.setMetaInfo(MetaInfo.HIDDEN_EDGES, isHiddenMap);
// discover triconnected components
TCSkeleton mainSkeleton = new TCSkeleton(this.graph,this.e2o);
this.splitOffInitialMultipleEdges(mainSkeleton,components,virtualEdgeMap,assignedVirtEdgeMap,isHiddenMap);
this.findSplitComponents(mainSkeleton,components,virtualEdgeMap,assignedVirtEdgeMap,isHiddenMap,meta,backEdge.getV1());
// construct TCTreeNodes and TCSkeletons from components
for (EdgeList el : components) {
if (components.size()<=1) continue;
TCTreeNode node = new TCTreeNode();
for (E edge : el) {
if (virtualEdgeMap.getBool(edge))
node.skeleton.addVirtualEdge(edge.getV1(),edge.getV2(),edge.getId());
else
node.skeleton.addEdge(edge.getV1(),edge.getV2(),this.e2o.get(edge));
}
this.addVertex(node);
}
// classify triconnected components into polygons, bonds, and rigids
this.classifyComponents();
// construct index
Map