public class Graph extends Object
| Modifier and Type | Field and Description |
|---|---|
List<EdgeFrom>[] |
edgesTo
边,到达下标i
|
Vertex[] |
vertexes
顶点
|
| Modifier and Type | Method and Description |
|---|---|
void |
connect(int from,
int to,
double weight)
连接两个节点
|
List<EdgeFrom> |
getEdgeListTo(int to)
获取到达顶点to的边列表
|
List<EdgeFrom>[] |
getEdgesTo() |
Vertex[] |
getVertexes() |
List<Vertex> |
parsePath(int[] path)
根据节点下标数组解释出对应的路径
|
static String |
parseResult(List<Vertex> path)
从一个路径中转换出空格隔开的结果
|
String |
printByTo() |
String |
toString() |
public Graph(Vertex[] vertexes)
vertexes - 顶点数组public void connect(int from,
int to,
double weight)
from - 起点to - 终点weight - 花费public List<EdgeFrom> getEdgeListTo(int to)
to - 到达顶点topublic String printByTo()
public static String parseResult(List<Vertex> path)
path - public Vertex[] getVertexes()
Copyright © 2014–2021 码农场. All rights reserved.