Interface WeightedGraph<V>
- Type Parameters:
V- the vertex type | 顶点类型
- All Superinterfaces:
Graph<V>
Weighted Graph
加权图
Interface for weighted graph operations with additional weight-related methods.
加权图操作接口,包含额外的权重相关方法。
Features | 特性:
- All Graph operations | 所有Graph操作
- Weight modification | 权重修改
- Total weight calculation | 总权重计算
Usage Examples | 使用示例:
WeightedGraph<String> graph = WeightedGraph.directed();
graph.addEdge("A", "B", 5.0);
graph.setWeight("A", "B", 10.0);
double total = graph.totalWeight();
Security | 安全性:
- Thread-safe: Depends on implementation - 线程安全: 取决于实现
- Null-safe: Yes (rejects null vertices) - 空值安全: 是(拒绝null顶点)
- Since:
- JDK 25, opencode-base-graph V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> WeightedGraph<V> directed()Create a directed weighted graph 创建有向加权图edgesInWeightRange(double minWeight, double maxWeight) Get edges with weight in range 获取权重在范围内的边default doubleGet the maximum edge weight 获取最大边权重default doubleGet the minimum edge weight 获取最小边权重booleanSet the weight of an edge 设置边的权重default doubleGet the total weight of all edges 获取所有边的总权重static <V> WeightedGraph<V> Create an undirected weighted graph 创建无向加权图Methods inherited from interface Graph
addEdge, addEdge, addVertex, clear, containsEdge, containsVertex, edgeCount, edges, getWeight, inDegree, inEdges, isDirected, isEmpty, neighbors, outDegree, outEdges, removeEdge, removeVertex, snapshot, vertexCount, vertices
-
Method Details
-
setWeight
-
totalWeight
default double totalWeight()Get the total weight of all edges 获取所有边的总权重- Returns:
- total weight | 总权重
-
minWeight
default double minWeight()Get the minimum edge weight 获取最小边权重- Returns:
- minimum weight, or Double.MAX_VALUE if no edges | 最小权重,如果无边则返回Double.MAX_VALUE
-
maxWeight
default double maxWeight()Get the maximum edge weight 获取最大边权重- Returns:
- maximum weight, or Double.MIN_VALUE if no edges | 最大权重,如果无边则返回Double.MIN_VALUE
-
edgesInWeightRange
-
directed
Create a directed weighted graph 创建有向加权图- Type Parameters:
V- the vertex type | 顶点类型- Returns:
- a new directed weighted graph | 新的有向加权图
-
undirected
Create an undirected weighted graph 创建无向加权图- Type Parameters:
V- the vertex type | 顶点类型- Returns:
- a new undirected weighted graph | 新的无向加权图
-