com.yworks.util.graph.Node Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yguard Show documentation
Show all versions of yguard Show documentation
The open-source Java obfuscation tool working with Ant and Gradle by yWorks - the diagramming experts
package com.yworks.util.graph;
import com.google.common.graph.Network;
import java.util.Iterator;
import java.util.Set;
public class Node {
private Network network;
public Node(Network network) {
this.network = network;
}
/**
* Returns all outgoing edges of this node.
* @return {Set}
*/
public Set outEdges() {
return this.network.outEdges(this);
}
/**
* Returns all ingoing edges of this node.
* @return {Set}
*/
public Set inEdges() {
return this.network.inEdges(this);
}
/**
* Returns the first outgoing edge for this node, if any.
* @return {Edge|null}
*/
public Edge firstOutEdge() {
Iterator outEdgesIterator = this.network.outEdges(this).iterator();
if (outEdgesIterator.hasNext()) {
return outEdgesIterator.next();
}
return null;
}
/**
* Returns the first ingoing edge for this node, if any.
* @return {Edge|null}
*/
public Edge firstInEdge() {
Iterator inEdgesIterator = this.network.inEdges(this).iterator();
if (inEdgesIterator.hasNext()) {
return inEdgesIterator.next();
}
return null;
}
/**
* Returns the edge directly connecting to this node, if any.
* @param node - the node which you would like to know the edge for.
* @return {Edge|null}
*/
public Edge getEdgeTo(Node node) {
Set connectingEdges = this.network.edgesConnecting(this, node);
if (connectingEdges.iterator().hasNext()) {
return connectingEdges.iterator().next();
}
return null;
}
}