List of usage examples for com.google.common.graph ImmutableValueGraph copyOf
@Deprecated public static <N, V> ImmutableValueGraph<N, V> copyOf(ImmutableValueGraph<N, V> graph)
From source file:no.ssb.vtl.script.operations.hierarchy.HierarchyOperation.java
@VisibleForTesting HierarchyOperation(Dataset dataset, ValueGraph<VTLObject, Composition> graph, Component component) { this(dataset, dataset, component); checkNotNull(graph);/*www .j av a 2 s . c o m*/ checkArgument(graph.isDirected()); checkArgument(!graph.allowsSelfLoops()); this.graph = ImmutableValueGraph.copyOf(graph); }
From source file:no.ssb.vtl.script.operations.hierarchy.HierarchyOperation.java
private List<VTLObject> getGraphValues() { if (this.graph == null) { // TODO: Hierarchy should be typed. this.graph = ImmutableValueGraph.copyOf(convertToHierarchy(this.hierarchy)); }/* ww w. ja v a 2 s .co m*/ if (this.graphValues == null) { this.graphValues = sortTopologically(this.graph); } return this.graphValues; }
From source file:org.jgrapht.graph.guava.ImmutableValueGraphAdapter.java
/** * Returns a shallow copy of this graph instance. Neither edges nor vertices are cloned. * * @return a shallow copy of this graph. * * @throws RuntimeException in case the clone is not supported * * @see java.lang.Object#clone()//from w w w . j a v a 2s. co m */ @Override public Object clone() { try { ImmutableValueGraphAdapter<V, W> newGraph = TypeUtil.uncheckedCast(super.clone()); newGraph.unmodifiableVertexSet = null; newGraph.unmodifiableEdgeSet = null; newGraph.valueConverter = this.valueConverter; newGraph.valueGraph = ImmutableValueGraph.copyOf(Graphs.copyOf(this.valueGraph)); return newGraph; } catch (CloneNotSupportedException e) { e.printStackTrace(); throw new RuntimeException(); } }
From source file:org.jgrapht.graph.guava.ImmutableValueGraphAdapter.java
@SuppressWarnings("unchecked") private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { ois.defaultReadObject();//from ww w . j av a 2 s. c om GraphType type = (GraphType) ois.readObject(); if (type.isMixed() || type.isAllowingMultipleEdges()) { throw new IOException("Graph type not supported"); } MutableValueGraph<V, W> mutableValueGraph = (type.isDirected() ? ValueGraphBuilder.directed() : ValueGraphBuilder.undirected()).allowsSelfLoops(type.isAllowingSelfLoops()).build(); // read vertices int n = ois.readInt(); for (int i = 0; i < n; i++) { V v = (V) ois.readObject(); mutableValueGraph.addNode(v); } // read edges int m = ois.readInt(); for (int i = 0; i < m; i++) { V s = (V) ois.readObject(); V t = (V) ois.readObject(); W w = (W) ois.readObject(); mutableValueGraph.putEdgeValue(s, t, w); } // setup the immutable copy this.valueGraph = ImmutableValueGraph.copyOf(mutableValueGraph); }