当前位置: 首页>>代码示例>>Java>>正文


Java Factory.create方法代码示例

本文整理汇总了Java中org.apache.commons.collections15.Factory.create方法的典型用法代码示例。如果您正苦于以下问题:Java Factory.create方法的具体用法?Java Factory.create怎么用?Java Factory.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.collections15.Factory的用法示例。


在下文中一共展示了Factory.create方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GraphViewerPanelManager

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
public GraphViewerPanelManager(TopologyManagerFrame frame, String projectType, File projectPath, TopologyViewerConfigManager viewerConfigPath,
                               File graphmlFile, Factory<G> factory, JTabbedPane tabbedPane,
                               GraphType graphType, GraphViewerPanelFactory graphViewerPanelFactory) throws Exception {
    this.frame = frame;
    this.projectPath = projectPath;
    this.graphType = graphType;
    this.viewerConfigManager = viewerConfigPath;
    versionDir = new File(new File(graphmlFile.getParent()).getParent());
   // TODO remove this Hardcode
    this.deviceXmlPath = versionDir;
    this.graphmlFileName = graphmlFile;
    this.factory = factory;
    this.tabbedPane = tabbedPane;
    entireGraph = factory.create();
    viewerConfig = viewerConfigManager.getTopologyViewerConfType();
    this.layout="FRLayout";
    this.graphViewerPanelFactory = graphViewerPanelFactory;
}
 
开发者ID:iTransformers,项目名称:netTransformer,代码行数:19,代码来源:GraphViewerPanelManager.java

示例2: toUndirected

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
/**
 * Transforms <code>graph</code> (which may be of any directionality)
 * into an undirected graph. (This may be useful for
 * visualization tasks).
 * Specifically:
 * <ul>
 * <li/>Vertices are copied from <code>graph</code>.
 * <li/>Directed edges are 'converted' into a single new undirected edge in the new graph.
 * <li/>Each undirected edge (if any) in <code>graph</code> is 'recreated' with a new undirected edge in the new
 * graph if <code>create_new</code> is true, or copied from <code>graph</code> otherwise.
 * </ul>
 * 
 * @param graph     the graph to be transformed
 * @param create_new specifies whether existing undirected edges are to be copied or recreated
 * @param graph_factory used to create the new graph object
 * @param edge_factory used to create new edges
 * @return          the transformed <code>Graph</code>
 */
public static <V,E> UndirectedGraph<V,E> toUndirected(Graph<V,E> graph, 
		Factory<UndirectedGraph<V,E>> graph_factory,
        Factory<E> edge_factory, boolean create_new)
{
    UndirectedGraph<V,E> out = graph_factory.create();
    
    for (V v : graph.getVertices())
        out.addVertex(v);
    
    for (E e : graph.getEdges())
    {
        Pair<V> endpoints = graph.getEndpoints(e);
        V v1 = endpoints.getFirst();
        V v2 = endpoints.getSecond();
        E to_add;
        if (graph.getEdgeType(e) == EdgeType.DIRECTED || create_new)
            to_add = edge_factory.create();
        else
            to_add = e;
        out.addEdge(to_add, v1, v2, EdgeType.UNDIRECTED);
    }
    return out;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:42,代码来源:DirectionTransformer.java

示例3: createAddEdge

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected E createAddEdge(StringTokenizer st, V v1, 
        EdgeType directed, Graph<V,E> g, List<V> id, Factory<E> edge_factory)
{
    int vid2 = Integer.parseInt(st.nextToken()) - 1;
    V v2;
    if (id != null)
      v2 = id.get(vid2);
    else
      v2 = (V)new Integer(vid2);
    E e = edge_factory.create();

    // don't error-check this: let the graph implementation do whatever it's going to do 
    // (add the edge, replace the existing edge, throw an exception--depends on the graph implementation)
 	g.addEdge(e, v1, v2, directed);
    return e;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:18,代码来源:PajekNetReader.java

示例4: matrixToGraph

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
/**
 * Creates a graph from a square (weighted) adjacency matrix.  If 
 * <code>nev</code> is non-null then it will be used to store the edge weights.
 * 
 * <p>Notes on implementation: 
 * <ul>
 * <li>The matrix indices will be mapped onto vertices in the order in which the
 * vertex factory generates the vertices.  This means the user is responsible
 * <li>The type of edges created (directed or undirected) depends
 * entirely on the graph factory supplied, regardless of whether the 
 * matrix is symmetric or not.  The Colt {@code Property.isSymmetric} 
 * method may be used to find out whether the matrix
 * is symmetric prior to making this call.
 * <li>The matrix supplied need not be square.  If it is not square, then 
 * the 
 * 
 * @return a representation of <code>matrix</code> as a JUNG
 *         <code>Graph</code>
 */
public static <V,E> Graph<V,E> matrixToGraph(DoubleMatrix2D matrix, 
		Factory<? extends Graph<V,E>> graphFactory,
		Factory<V> vertexFactory, Factory<E> edgeFactory, 
		Map<E,Number> nev)
{
    if (matrix.rows() != matrix.columns())
    {
        throw new IllegalArgumentException("Matrix must be square.");
    }
    int size = matrix.rows();

    Graph<V,E> graph = graphFactory.create();
    
    for(int i = 0; i < size; i++) 
    {
        V vertex = vertexFactory.create();
    	graph.addVertex(vertex);
    }

    List<V> vertices = new ArrayList<V>(graph.getVertices());
    for (int i = 0; i < size; i++)
    {
        for (int j = 0; j < size; j++)
        {
            double value = matrix.getQuick(i, j);
            if (value != 0)
            {
                E e = edgeFactory.create();
                if (graph.addEdge(e, vertices.get(i), vertices.get(j)))
                {
                    if (e != null && nev != null)
                        nev.put(e, value);
                }
            }
        }
    }
    
    
    return graph;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:60,代码来源:GraphMatrixOperations.java

示例5: generateMixedRandomGraph

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
/**
 * Returns a random mixed-mode graph.  Starts with a randomly generated 
 * Barabasi-Albert (preferential attachment) generator 
 * (4 initial vertices, 3 edges added at each step, and num_vertices - 4 evolution steps).
 * Then takes the resultant graph, replaces random undirected edges with directed
 * edges, and assigns random weights to each edge.
 */
public static <V,E> Graph<V,E> generateMixedRandomGraph(
		Factory<Graph<V,E>> graphFactory,
		Factory<V> vertexFactory,
		Factory<E> edgeFactory,
		Map<E,Number> edge_weights, 
        int num_vertices, boolean parallel, Set<V> seedVertices)
{
    int seed = (int)(Math.random() * 10000);
    BarabasiAlbertGenerator<V,E> bag = 
        new BarabasiAlbertGenerator<V,E>(graphFactory, vertexFactory, edgeFactory,
        		4, 3, //false, parallel, 
        		seed, seedVertices);
    bag.evolveGraph(num_vertices - 4);
    Graph<V, E> ug = bag.create();

    // create a SparseMultigraph version of g
    Graph<V, E> g = graphFactory.create();
    	//new SparseMultigraph<V, E>();
    for(V v : ug.getVertices()) {
    	g.addVertex(v);
    }
    
    // randomly replace some of the edges by directed edges to 
    // get a mixed-mode graph, add random weights
    
    for(E e : ug.getEdges()) {
        V v1 = ug.getEndpoints(e).getFirst();
        V v2 = ug.getEndpoints(e).getSecond();

        E me = edgeFactory.create();
        g.addEdge(me, v1, v2, Math.random() < .5 ? EdgeType.DIRECTED : EdgeType.UNDIRECTED);
        edge_weights.put(me, Math.random());
    }
    
    return g;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:44,代码来源:MixedRandomGraphGenerator.java

示例6: foldKPartiteGraph

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
/**
 * Converts <code>g</code> into a unipartite graph whose vertices are the
 * vertices of <code>g</code>'s partition <code>p</code>, and whose edges
 * consist of collections of the intermediate vertices from other partitions.  
 * For vertices
 * <code>a</code> and <code>b</code> in this partition, the resultant
 * graph will include the edge <code>(a,b)</code> if the original graph
 * contains edges <code>(a,c)</code> and <code>(c,b)</code> for at least
 * one vertex <code>c</code>.
 * 
 * <p>The vertices of the new graph are the same as the vertices of the
 * appropriate partition in the old graph; the edges in the new graph are
 * collections of the intermediate vertices <code>c</code>.</p>
 * 
 * <p>This function will not create self-loops.</p>
 * 
 * @param <V> vertex type
 * @param <E> input edge type
 * @param g input k-partite graph
 * @param p predicate specifying vertex partition
 * @param graph_factory factory used to create the output graph 
 * @return the result of folding g into unipartite graph whose vertices
 * are those of the <code>p</code> partition of g
 */
public static <V,E> Graph<V, Collection<V>> foldKPartiteGraph(KPartiteGraph<V,E> g, Predicate<V> p, 
        Factory<Graph<V, Collection<V>>> graph_factory)
{
    Graph<V, Collection<V>> newGraph = graph_factory.create();

    // get vertices for the specified partition, copy into new graph
    Collection<V> vertices = g.getVertices(p);

    for (V v : vertices)
    {
        newGraph.addVertex(v);
        for (V s : g.getSuccessors(v))
        {
            for (V t : g.getSuccessors(s))
            {
                if (!vertices.contains(t) || t.equals(v)) 
                    continue;
                newGraph.addVertex(t);
                Collection<V> v_coll = newGraph.findEdge(v, t);
                if (v_coll == null)
                {
                    v_coll = new ArrayList<V>();
                    newGraph.addEdge(v_coll, v, t);
                }
                v_coll.add(s);
            }
        }
    }
    return newGraph;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:55,代码来源:FoldingTransformer.java

示例7: toDirected

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
/**
 * Transforms <code>graph</code> (which may be of any directionality)
 * into a directed graph.  
 * Specifically:
 * <ul>
 * <li/>Vertices are copied from <code>graph</code>.
 * <li/>Undirected edges are 'converted' into two new antiparallel directed edges in the new graph.
 * <li/>Each directed edge (if any) in <code>graph</code> is 'recreated' with a new edge in the new
 * graph if <code>create_new</code> is true, or copied from <code>graph</code> otherwise.
 * </ul>
 * 
 * @param graph     the graph to be transformed
 * @param create_new specifies whether existing directed edges are to be copied or recreated
 * @param graph_factory used to create the new graph object
 * @param edge_factory used to create new edges
 * @return          the transformed <code>Graph</code>
 */
public static <V,E> Graph<V,E> toDirected(Graph<V,E> graph, Factory<DirectedGraph<V,E>> graph_factory,
        Factory<E> edge_factory, boolean create_new)
{
    DirectedGraph<V,E> out = graph_factory.create();
    
    for (V v : graph.getVertices())
        out.addVertex(v);
    
    for (E e : graph.getEdges())
    {
        Pair<V> endpoints = graph.getEndpoints(e);
        if (graph.getEdgeType(e) == EdgeType.UNDIRECTED)
        {
            V v1 = endpoints.getFirst();
            V v2 = endpoints.getSecond();
            out.addEdge(edge_factory.create(), v1, v2, EdgeType.DIRECTED);
            out.addEdge(edge_factory.create(), v2, v1, EdgeType.DIRECTED);
        }
        else // if the edge is directed, just add it 
        {
            V source = graph.getSource(e);
            V dest = graph.getDest(e);
            E to_add = create_new ? edge_factory.create() : e;
            out.addEdge(to_add, source, dest, EdgeType.DIRECTED);
        }
            
    }
    return out;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:47,代码来源:DirectionTransformer.java

示例8: TransferProgressVisualizer

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
public TransferProgressVisualizer(DataVertex startVertex, DataVertex endVertex, Factory<? extends DataVertexEdge> dataTransferEdgeFactory,
        Timer migrationStateUpdateTimer, Graph<NubiSaveVertex, NubiSaveEdge> graph, VisualizationViewer<NubiSaveVertex, NubiSaveEdge> vv) {
    this.startVertex = startVertex;
    this.endVertex = endVertex;
    start = (AbstractNubisaveComponent) ((VertexGroup) startVertex).getParentComponent();
    this.dataTransferEdgeFactory = dataTransferEdgeFactory;
    this.migrationStateUpdateTimer = migrationStateUpdateTimer;
    this.vv = vv;
    this.graph = graph;
    dataTransferEdge = dataTransferEdgeFactory.create();
    graph.addEdge(dataTransferEdge, startVertex, endVertex);
    dataTransferEdge.setTransferProgress(start.getMigrationProgress());
}
 
开发者ID:joe42,项目名称:nubisave,代码行数:14,代码来源:TransferProgressVisualizer.java

示例9: foldHypergraphEdges

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
/**
 * Creates a <code>Graph</code> which is an edge-folded version of <code>h</code>, where
 * hyperedges are replaced by k-cliques in the output graph.
 * 
 * <p>The vertices of the new graph are the same objects as the vertices of 
 * <code>h</code>, and <code>a</code> 
 * is connected to <code>b</code> in the new graph if the corresponding vertices
 * in <code>h</code> are connected by a hyperedge.  Thus, each hyperedge with 
 * <i>k</i> vertices in <code>h</code> induces a <i>k</i>-clique in the new graph.</p>
 * 
 * <p>The edges of the new graph consist of collections of each hyperedge that connected
 * the corresponding vertex pair in the original graph.</p>
 * 
 * @param <V> vertex type
 * @param <E> input edge type
 * @param h hypergraph to be folded
 * @param graph_factory factory used to generate the output graph
 * @return a copy of the input graph where hyperedges are replaced by cliques
 */
public static <V,E> Graph<V, Collection<E>> foldHypergraphEdges(Hypergraph<V,E> h, 
        Factory<Graph<V, Collection<E>>> graph_factory)
{
    Graph<V, Collection<E>> target = graph_factory.create();

    for (V v : h.getVertices())
        target.addVertex(v);
    
    for (E e : h.getEdges())
    {
        ArrayList<V> incident = new ArrayList<V>(h.getIncidentVertices(e));
        populateTarget(target, e, incident);
    }
    return target;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:35,代码来源:FoldingTransformer.java

示例10: foldHypergraphVertices

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
/**
 * Creates a <code>Graph</code> which is a vertex-folded version of <code>h</code>, whose
 * vertices are the input's hyperedges and whose edges are induced by adjacent hyperedges
 * in the input.
 * 
 * <p>The vertices of the new graph are the same objects as the hyperedges of 
 * <code>h</code>, and <code>a</code> 
 * is connected to <code>b</code> in the new graph if the corresponding edges
 * in <code>h</code> have a vertex in common.  Thus, each vertex incident to  
 * <i>k</i> edges in <code>h</code> induces a <i>k</i>-clique in the new graph.</p>
 * 
 * <p>The edges of the new graph are created by the specified factory.</p>
 * 
 * @param <V> vertex type
 * @param <E> input edge type
 * @param <F> output edge type
 * @param h hypergraph to be folded
 * @param graph_factory factory used to generate the output graph
 * @param edge_factory factory used to generate the output edges
 * @return a transformation of the input graph whose vertices correspond to the input's hyperedges 
 * and edges are induced by hyperedges sharing vertices in the input
 */
public static <V,E,F> Graph<E,F> foldHypergraphVertices(Hypergraph<V,E> h, 
        Factory<Graph<E,F>> graph_factory, Factory<F> edge_factory)
{
    Graph<E,F> target = graph_factory.create();
    
    for (E e : h.getEdges())
        target.addVertex(e);
    
    for (V v : h.getVertices())
    {
        ArrayList<E> incident = new ArrayList<E>(h.getIncidentEdges(v));
        for (int i = 0; i < incident.size(); i++)
            for (int j = i+1; j < incident.size(); j++)
                target.addEdge(edge_factory.create(), incident.get(i), incident.get(j));
    }
    
    return target;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:41,代码来源:FoldingTransformer.java

示例11: DelegateTree

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
/**
 * create an instance with passed values.
 * @param graphFactory must create a DirectedGraph to use as a delegate
 */
public DelegateTree(Factory<DirectedGraph<V,E>> graphFactory) {
	super(graphFactory.create());
       this.vertex_depths = new HashMap<V, Integer>();
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:9,代码来源:DelegateTree.java

示例12: MinimumSpanningForest2

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
/**
 * create a Forest from the supplied Graph and supplied Factory, which
 * is used to create a new, empty Forest. If non-null, the supplied root
 * will be used as the root of the tree/forest. If the supplied root is
 * null, or not present in the Graph, then an arbitary Graph vertex
 * will be selected as the root.
 * If the Minimum Spanning Tree does not include all vertices of the
 * Graph, then a leftover vertex is selected as a root, and another
 * tree is created
 * @param graph
 * @param factory
 * @param weights
 */
public MinimumSpanningForest2(Graph<V, E> graph, 
		Factory<Forest<V,E>> factory, 
		Factory<? extends Graph<V,E>> treeFactory,
		Transformer<E, Double> weights) {
	this(graph, factory.create(), 
			treeFactory, 
			weights);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:22,代码来源:MinimumSpanningForest2.java

示例13: MinimumSpanningForest

import org.apache.commons.collections15.Factory; //导入方法依赖的package包/类
/**
 * Creates a Forest from the supplied Graph and supplied Factory, which
 * is used to create a new, empty Forest. If non-null, the supplied root
 * will be used as the root of the tree/forest. If the supplied root is
 * null, or not present in the Graph, then an arbitrary Graph vertex
 * will be selected as the root.
 * If the Minimum Spanning Tree does not include all vertices of the
 * Graph, then a leftover vertex is selected as a root, and another
 * tree is created.
 * @param graph the input graph
 * @param factory the factory to use to create the new forest
 * @param root the vertex of the graph to be used as the root of the forest 
 * @param weights edge weights
 */
public MinimumSpanningForest(Graph<V, E> graph, Factory<Forest<V,E>> factory, 
		V root, Map<E, Double> weights) {
	this(graph, factory.create(), root, weights);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:19,代码来源:MinimumSpanningForest.java


注:本文中的org.apache.commons.collections15.Factory.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。