图(Graph)-边缘

1,抽象数据类型:

public abstract class Graph {
	public abstract int vertices();
	public abstract int edges();
	public abstract boolean existsEdge(int i, int j);
	public abstract void putEdge(Object theEdge);
	public abstract void removeEdge(int i, int j);
	public abstract int degree(int i);
	public abstract int inDegree(int i);
	public abstract int outDegree(int i);
	public abstract Iterator iterator(int i);
}

2,节点定义:

public class Edge {
	int vertex1; // one end point of the edge
	int vertex2; // other end point of the edge

	public Edge(int theVertex1, int theVertex2) {
		vertex1 = theVertex1;
		vertex2 = theVertex2;
	}

	public String toString() {
		return "(" + String.valueOf(vertex1) + "," + String.valueOf(vertex2)
				+ ")";
	}
}

 

public class WeightedEdgeNode extends EdgeNode {
	Object weight;

	public WeightedEdgeNode(int theVertex, Object theWeight) {
		super(theVertex);
		weight = theWeight;
	}

	public String toString() {
		return String.valueOf(vertex) + " " + weight.toString();
	}
} 

3,继承关系图

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值