邻接矩阵图
SeqList类(线性表类):
public class SeqList {
final int defaultSize = 10;
int maxSize;
int size;
Object[] listArray;
public SeqList() {
initiate(defaultSize);
}
public SeqList(int size) {
initiate(size);
}
private void initiate(int sz) {
maxSize = sz;
size = 0;
listArray = new Object[sz];
}
public void insert(int i , Object obj) throws Exception {
if (size == maxSize) {
throw new Exception("顺序表已满无法插入!");
}
if (i < 0 || i > size) {
throw new Exception("参数错误!");
}
for ( int j = size ; j > i ; j --) {
listArray[j] = listArray[j - 1];
}
listArray[i] = obj;
size++;
}
public Object delete(int i) throws Exception {
if (size == 0) {
throw new Exception("顺序表已空无法删除!");
}
if (i < 0 || i > size -