|
GraphLab Project | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgraphlab.plugins.main.core.AlgorithmUtils
public class AlgorithmUtils
Just some methods helping you to write Graph Algorithms easier,
LibraryUtils
Nested Class Summary | |
---|---|
static interface |
AlgorithmUtils.BFSListener<Vertex extends BaseVertex>
|
Field Summary | |
---|---|
static int |
Max_Int
|
Constructor Summary | |
---|---|
AlgorithmUtils()
|
Method Summary | ||
---|---|---|
static
|
BFS(BaseGraph<Vertex,Edge> unRootedTree,
AlgorithmUtils.BFSListener<Vertex> listener)
performs a full BFS on graph, it selects the vertices with minimum degrees as the roots of the resulting forest |
|
static
|
BFS(BaseGraph<Vertex,Edge> unRootedTree,
Vertex treeRoot,
AlgorithmUtils.BFSListener<Vertex> listener)
performs a bfs on the given root, this method changes vertex marks, and also marked vertices will not be traversed |
|
static
|
BFSOrder(BaseGraph<Vertex,Edge> unRootedTree,
Vertex treeRoot)
gets the vertices in the order of AlgorithmUtils.getSubTree() |
|
static
|
BFSrun(BaseGraph<Vertex,Edge> unRootedTree,
Vertex treeRoot,
AlgorithmUtils.BFSListener<Vertex> listener)
runs a BFS on graph, starting the given vertex as the root |
|
static
|
clearVertexMarks(BaseGraph<VertexType,EdgeType> g)
clears all vertex marks |
|
static
|
dfs(BaseGraph<VertexType,EdgeType> g,
int node,
java.util.ArrayList visit,
int[] parent)
runs a dfs and fills visit and parent, visit is the visiting order of vertices and parent[i] is the id of i'th vertex parent |
|
static
|
getAdjList(BaseGraph<VertexType,EdgeType> g)
Deprecated. use BaseGraph.getEdgeArray instead |
|
static double |
getAngle(GraphPoint p1,
GraphPoint p2)
|
|
static double |
getAngle(GraphPoint rootp,
GraphPoint v1p,
GraphPoint v2p)
returns the angle between 3 points |
|
static double |
getAngle(VertexModel root,
VertexModel v1,
VertexModel v2)
returns the angle between 3 vertices in graphical world! |
|
static java.awt.geom.Rectangle2D.Double |
getBoundingRegion(java.util.Collection<VertexModel> vertices)
|
|
static GraphPoint |
getCenter(java.util.Collection<VertexModel> V)
|
|
static
|
getDegree(BaseGraph<VertexType,EdgeType> bg,
int node)
Deprecated. |
|
static
|
getDegreesList(BaseGraph<VertexType,EdgeType> g)
returns the vertex degrees as a list, sorted by vertex ids |
|
static double |
getDistance(GraphPoint p1,
GraphPoint p2)
returns the distance between two points |
|
static double |
getDistance(VertexModel v1,
VertexModel v2)
returns the distance between two vertices in pixels, (in graphics not the path length between them) |
|
static double |
getLength(double dx,
double dy)
returns the length of the given vector |
|
static GraphPoint |
getMiddlePoint(GraphPoint p1,
GraphPoint p2)
|
|
static
|
getNeighbors(BaseGraph<VertexType,EdgeType> g,
VertexType source)
Deprecated. |
|
static
|
getNeighbors2(BaseGraph<VertexType,EdgeType> g,
VertexType source)
Deprecated. |
|
static
|
getParent(BaseGraph<VertexType,EdgeType> g,
VertexType treeRoot,
VertexType v)
returns the parent of v, if ve DFS on parent |
|
static
|
getPath(BaseGraph<VertexType,EdgeType> g,
VertexType source,
VertexType dest)
returns a path from source to target path.get(0) = dest |
|
static
|
getRoot(BaseGraph<Vertex,Edge> g,
Vertex v)
returns the root which is assigned to each vertex it is the minimum id vertex in the corresponding component of vertex |
|
static
|
getSubTree(BaseGraph<Vertex,Edge> tree,
Vertex treeRoot,
Vertex subTreeRoot)
returns the subtree rooted by subTreeRoot in the rooted tree tree with the root treeRoot the vertices are ordered by their distances to subTreeRoot the exact distance is placed in v.getProp().obj as an Integer, starting distance is 0 which is subTreeRoot |
|
static int |
getTotalDegree(BaseGraph g,
BaseVertex v)
retunrs the degree of vertex (indegree + outdegree) |
|
static
|
isCompleteGraph(BaseGraph<VertexType,EdgeType> g)
determines wether g is complete or not |
|
static
|
isConnected(BaseGraph<VertexType,EdgeType> g)
determines wether g is connected or not |
|
static void |
move(VertexModel v,
double dx,
double dy)
moves the vertex relative to its current position |
|
static GraphPoint |
normalize(GraphPoint vector)
|
|
static void |
resetVertexColors(BaseGraph<BaseVertex,BaseEdge<BaseVertex>> g)
sets all vertex colors to 0. |
|
static void |
resetVertexMarks(BaseGraph<BaseVertex,BaseEdge<BaseVertex>> g)
sets all vertex marks to false |
|
static void |
setLocation(VertexModel v,
GraphPoint center,
double radius,
double ang)
locations v in a r-teta cordination |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int Max_Int
Constructor Detail |
---|
public AlgorithmUtils()
Method Detail |
---|
public static void resetVertexColors(BaseGraph<BaseVertex,BaseEdge<BaseVertex>> g)
public static void resetVertexMarks(BaseGraph<BaseVertex,BaseEdge<BaseVertex>> g)
public static <VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>> boolean isConnected(BaseGraph<VertexType,EdgeType> g)
public static <VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>> boolean isCompleteGraph(BaseGraph<VertexType,EdgeType> g)
public static <VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>> java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> getAdjList(BaseGraph<VertexType,EdgeType> g)
public static <VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>> int getDegree(BaseGraph<VertexType,EdgeType> bg, int node)
BaseGraph.getDegree(graphlab.library.BaseVertex)
public static <VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>> java.util.ArrayList<VertexType> getNeighbors(BaseGraph<VertexType,EdgeType> g, VertexType source)
BaseGraph.getNeighbors(graphlab.library.BaseVertex)
public static <VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>> java.util.ArrayList<VertexType> getNeighbors2(BaseGraph<VertexType,EdgeType> g, VertexType source)
BaseGraph.getNeighbors(graphlab.library.BaseVertex)
public static <VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>> Path<VertexType> getPath(BaseGraph<VertexType,EdgeType> g, VertexType source, VertexType dest)
public static <VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>> VertexType getParent(BaseGraph<VertexType,EdgeType> g, VertexType treeRoot, VertexType v)
public static <VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>> void clearVertexMarks(BaseGraph<VertexType,EdgeType> g)
public static <Vertex extends BaseVertex,Edge extends BaseEdge<Vertex>> java.util.ArrayList<Vertex> getSubTree(BaseGraph<Vertex,Edge> tree, Vertex treeRoot, Vertex subTreeRoot)
public static <Vertex extends BaseVertex,Edge extends BaseEdge<Vertex>> java.util.ArrayList<Vertex> BFSOrder(BaseGraph<Vertex,Edge> unRootedTree, Vertex treeRoot)
public static <Vertex extends BaseVertex,Edge extends BaseEdge<Vertex>> void BFSrun(BaseGraph<Vertex,Edge> unRootedTree, Vertex treeRoot, AlgorithmUtils.BFSListener<Vertex> listener)
public static <Vertex extends BaseVertex,Edge extends BaseEdge<Vertex>> void BFS(BaseGraph<Vertex,Edge> unRootedTree, AlgorithmUtils.BFSListener<Vertex> listener)
unRootedTree
- listener
- public static <Vertex extends BaseVertex,Edge extends BaseEdge<Vertex>> java.util.ArrayList<Vertex> BFS(BaseGraph<Vertex,Edge> unRootedTree, Vertex treeRoot, AlgorithmUtils.BFSListener<Vertex> listener)
unRootedTree
- treeRoot
- listener
-
public static <VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>> void dfs(BaseGraph<VertexType,EdgeType> g, int node, java.util.ArrayList visit, int[] parent)
public static int getTotalDegree(BaseGraph g, BaseVertex v)
public static <Vertex extends BaseVertex,Edge extends BaseEdge<Vertex>> Vertex getRoot(BaseGraph<Vertex,Edge> g, Vertex v)
public static double getAngle(VertexModel root, VertexModel v1, VertexModel v2)
public static double getAngle(GraphPoint rootp, GraphPoint v1p, GraphPoint v2p)
public static double getLength(double dx, double dy)
public static void move(VertexModel v, double dx, double dy)
public static double getDistance(VertexModel v1, VertexModel v2)
public static double getDistance(GraphPoint p1, GraphPoint p2)
public static double getAngle(GraphPoint p1, GraphPoint p2)
public static void setLocation(VertexModel v, GraphPoint center, double radius, double ang)
public static java.awt.geom.Rectangle2D.Double getBoundingRegion(java.util.Collection<VertexModel> vertices)
public static GraphPoint getCenter(java.util.Collection<VertexModel> V)
public static <VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>> java.util.ArrayList<java.lang.Integer> getDegreesList(BaseGraph<VertexType,EdgeType> g)
public static GraphPoint getMiddlePoint(GraphPoint p1, GraphPoint p2)
p1
- p2
-
public static GraphPoint normalize(GraphPoint vector)
|
GraphLab Project | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |