Commit bbb1881c authored by Fokion Zervoudakis's avatar Fokion Zervoudakis

Remove static imports.

parent 444d061c
......@@ -3,15 +3,12 @@ package graph;
import java.util.Deque;
import java.util.LinkedList;
import static graph.Color.BLACK;
import static graph.Color.WHITE;
class Bfs2 {
boolean isBipartite(Graph<Vertex> G, Vertex start) {
Deque<Vertex> Q = new LinkedList<>();
Q.add(start);
start.visited = true;
start.color = WHITE;
start.color = Color.WHITE;
while (!Q.isEmpty()) {
Vertex u = Q.removeFirst();
for (Vertex v : G.outEdges(u)) {
......@@ -40,7 +37,7 @@ class Bfs2 {
}
Color complement() {
return (color == WHITE) ? BLACK : WHITE;
return (color == Color.WHITE) ? Color.BLACK : Color.WHITE;
}
@Override
......
package graph;
import static graph.Color.BLACK;
import static graph.Color.GRAY;
import static graph.Color.WHITE;
class Dfs2 {
/**
Uses recursive depth-first search to detect cycles in a directed acyclic
......@@ -17,21 +13,21 @@ class Dfs2 {
@param G a graph
*/
void dfs(Graph<Vertex> G, Vertex u) {
u.color = GRAY;
u.color = Color.GRAY;
for (Vertex v : G.outEdges(u)) {
if (v.color == GRAY) {
if (v.color == Color.GRAY) {
throw new RuntimeException();
} else if (v.color == WHITE) {
} else if (v.color == Color.WHITE) {
v.setParent(u);
v.color = GRAY;
v.color = Color.GRAY;
dfs(G, v);
}
}
u.color = BLACK;
u.color = Color.BLACK;
}
static class Vertex extends graph.Vertex {
Color color = WHITE;
Color color = Color.WHITE;
Vertex(int key) {
super(key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment