T
- 点对象类型public class DirectedWeightGraph<T> extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DirectedWeightGraph.Edge<T>
边
|
static class |
DirectedWeightGraph.NegativeRingException
负环异常
|
static class |
DirectedWeightGraph.Path<T>
路径
|
Constructor and Description |
---|
DirectedWeightGraph() |
Modifier and Type | Method and Description |
---|---|
Map<T,DirectedWeightGraph.Path<T>> |
bestPathMap(T startPoint)
计算 从 startPoint 到 所有点 最短路径
基于 SPFA 算法实现
|
Set<T> |
getAllPoints()
获取全部点
|
void |
putEdge(T fromPoint,
T nextPoint,
long weight)
添加边
|
void |
removeEdge(T fromPoint,
T nextPoint)
删除边
|
void |
removePoint(T point)
删除点
|
String |
toString() |
public void putEdge(T fromPoint, T nextPoint, long weight)
fromPoint
- 开始点nextPoint
- 结束点weight
- 权重public void removeEdge(T fromPoint, T nextPoint)
fromPoint
- 开始点nextPoint
- 结束点public void removePoint(T point)
point
- 点public Map<T,DirectedWeightGraph.Path<T>> bestPathMap(T startPoint) throws DirectedWeightGraph.NegativeRingException
startPoint
- 开始节点DirectedWeightGraph.NegativeRingException
- 存在负权环路Copyright © 2025. All rights reserved.