com.google.javascript.jscomp.graph.DiGraph Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of closure-compiler-linter Show documentation
Show all versions of closure-compiler-linter Show documentation
Closure Compiler is a JavaScript optimizing compiler. It parses your
JavaScript, analyzes it, removes dead code and rewrites and minimizes
what's left. It also checks syntax, variable references, and types, and
warns about common JavaScript pitfalls. It is used in many of Google's
JavaScript apps, including Gmail, Google Web Search, Google Maps, and
Google Docs.
This binary checks for style issues such as incorrect or missing JSDoc
usage, and missing goog.require() statements. It does not do more advanced
checks such as typechecking.
/*
* Copyright 2008 The Closure Compiler Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.javascript.jscomp.graph;
import java.util.List;
/**
* A generic directed graph.
*
*
* @param Value type that the graph node stores.
* @param Value type that the graph edge stores.
*/
public abstract class DiGraph extends Graph {
/**
* Gets an immutable iterable over all the nodes in the graph.
*/
public abstract Iterable> getDirectedGraphNodes();
/**
* Gets an immutable list of out edges of the given node.
*/
public abstract List> getOutEdges(N nodeValue);
/**
* Gets an immutable list of in edges of the given node.
*/
public abstract List> getInEdges(N nodeValue);
public abstract List> getDirectedPredNodes(
DiGraphNode n);
public abstract List> getDirectedPredNodes(N nodeValue);
public abstract List> getDirectedSuccNodes(
DiGraphNode n);
public abstract List>
getDirectedSuccNodes(N nodeValue);
public abstract DiGraphNode createDirectedGraphNode(N nodeValue);
public abstract DiGraphNode getDirectedGraphNode(N nodeValue);
public abstract List>
getDirectedGraphEdges(N n1, N n2);
/**
* Disconnects all edges from n1 to n2.
*
* @param n1 Source node.
* @param n2 Destination node.
*/
public abstract void disconnectInDirection(N n1, N n2);
/**
* Checks whether two nodes in the graph are connected via a directed edge.
*
* @param n1 Node 1.
* @param n2 Node 2.
* @return true
if the graph contains edge from n1 to n2.
*/
public abstract boolean isConnectedInDirection(N n1, N n2);
/**
* Checks whether two nodes in the graph are connected via a directed edge
* with the given value.
*
* @param n1 Node 1.
* @param edgeValue edge value tag
* @param n2 Node 2.
* @return true
if the edge exists.
*/
public abstract boolean isConnectedInDirection(N n1, E edgeValue, N n2);
@Override
public boolean isConnected(N n1, N n2) {
return isConnectedInDirection(n1, n2) || isConnectedInDirection(n2, n1);
}
@Override
public boolean isConnected(N n1, E e, N n2) {
return isConnectedInDirection(n1, e, n2) ||
isConnectedInDirection(n2, e, n1);
}
/**
* A generic directed graph node.
*
* @param Value type that the graph node stores.
* @param Value type that the graph edge stores.
*/
public static interface DiGraphNode extends GraphNode {
public List> getOutEdges();
public List> getInEdges();
}
/**
* A generic directed graph edge.
*
* @param Value type that the graph node stores.
* @param Value type that the graph edge stores.
*/
public static interface DiGraphEdge extends GraphEdge {
public DiGraphNode getSource();
public DiGraphNode getDestination();
public void setSource(DiGraphNode node);
public void setDestination(DiGraphNode node);
}
}