Class DiGraph<V>
java.lang.Object
com.sure.tool.graph.DiGraph<V>
- Type Parameters:
V- 顶点类型
简单有向图(邻接表实现),顶点去重基于
Object.equals(Object)/Object.hashCode()。
非线程安全;顶点/边均为轻量操作,适合小规模图建模与算法演示。 对标 Guava Graph 的核心子集。
- Since:
- 1.11.0
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean添加有向边(源 → 目标),两端顶点自动补齐。boolean添加顶点。addVertexIfAbsent(V vertex) 添加顶点(已存在时忽略)。adjacentNodes(V vertex) 邻接顶点集合(后继 ∪ 前驱)。booleancontainsEdge(V source, V target) 是否包含有向边(源 → 目标)。booleancontainsVertex(V vertex) 是否包含顶点。int度数(出度 + 入度)。int边数量。edges()全部有向边。int入度。int出度。predecessors(V vertex) 前驱顶点集合(入边来源)。booleanremoveEdge(V source, V target) 移除有向边。booleanremoveVertex(V vertex) 移除顶点及其全部关联边。successors(V vertex) 后继顶点集合(出边目标)。int顶点数量。vertices()全部顶点。
-
Constructor Details
-
DiGraph
public DiGraph()
-
-
Method Details
-
addVertex
-
addVertexIfAbsent
-
addEdge
-
removeVertex
-
removeEdge
-
containsVertex
-
containsEdge
-
vertexCount
public int vertexCount()顶点数量。- Returns:
- 顶点数
-
edgeCount
public int edgeCount()边数量。- Returns:
- 边数
-
vertices
-
edges
-
successors
-
predecessors
-
adjacentNodes
-
outDegree
-
inDegree
-
degree
-