java数据结构_附11_图的接口定义

图的接口定义 Graph

public class UnsupportedOperation extends RuntimeException {
public UnsupportedOperation(String err) {
super(err);
}
}

public interface Graph {
public static final int UndirectedGraph = 0;//无向图
public static final int DirectedGraph  = 1;//有向图
//返回图的类型
public int getType();
//返回图的顶点数
public int getVexNum();
//返回图的边数
public int getEdgeNum();
//返回图的所有顶点
public Iterator getVertex();
//返回图的所有边
public Iterator getEdge();
//删除一个顶点v
public void remove(Vertex v);
//删除一条边e
public void remove(Edge e);
//添加一个顶点v
public Node insert(Vertex v);
//添加一条边e
public Node insert(Edge e);
//判断顶点u、v是否邻接,即是否有边从u到v
public boolean areAdjacent(Vertex u, Vertex v);
//返回从u指向v的边,不存在则返回null
public Edge edgeFromTo(Vertex u, Vertex v);
//返回从u出发可以直接到达的邻接顶点
public Iterator adjVertexs(Vertex u);
//对图进行深度优先遍历
public Iterator DFSTraverse(Vertex v);
//对图进行广度优先遍历
public Iterator BFSTraverse(Vertex v);
//求顶点v到其他顶点的最短路径
public Iterator shortestPath(Vertex v);
//求无向图的最小生成树,如果是有向图不支持此操作
public void generateMST() throws UnsupportedOperation;
//求有向图的拓扑序列,无向图不支持此操作
public Iterator toplogicalSort() throws UnsupportedOperation;
//求有向无环图的关键路径,无向图不支持此操作
public void criticalPath() throws UnsupportedOperation;
}

转载于:https://www.cnblogs.com/foxspecial/p/3320927.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值