資源簡介

代碼片段和文件信息
import?java.util.*;
public?abstract?class?AbstractGraph?implements?Graph?{
??protected?List?vertices?=?new?ArrayList();?//?Store?vertices
??protected?List>?neighbors?
????=?new?ArrayList>();?//?Adjacency?lists
??/**?Construct?an?empty?graph?*/
??protected?AbstractGraph()?{
??}
??
??/**?Construct?a?graph?from?edges?and?vertices?stored?in?arrays?*/
??protected?AbstractGraph(int[][]?edges?V[]?vertices)?{
????for?(int?i?=?0;?i???????this.vertices.add(vertices[i]);
????
????createAdjacencyLists(edges?vertices.length);
??}
??/**?Construct?a?graph?from?edges?and?vertices?stored?in?List?*/
??protected?AbstractGraph(List?edges?List?vertices)?{
for?(int?i?=?0;?i? ??this.vertices.add(vertices.get(i));
????
createAdjacencyLists(edges?vertices.size());
??}
??/**?Construct?a?graph?for?integer?vertices?0?1?2?and?edge?list?*/
??protected?AbstractGraph(List?edges?int?numberOfVertices)?{
????for?(int?i?=?0;?i???????vertices.add((V)(new?Integer(i)));?//?vertices?is?{0?1?...}
????}
????createAdjacencyLists(edges?numberOfVertices);
??}
??/**?Construct?a?graph?from?integer?vertices?0?1?and?edge?array?*/
??protected?AbstractGraph(int[][]?edges?int?numberOfVertices)?{
????for?(int?i?=?0;?i???????vertices.add((V)(new?Integer(i)));?//?vertices?is?{0?1?...}
????}
????createAdjacencyLists(edges?numberOfVertices);
??}
??/**?Create?adjacency?lists?for?each?vertex?*/
??private?void?createAdjacencyLists(
??????int[][]?edges?int?numberOfVertices)?{
????//?Create?a?linked?list
????for?(int?i?=?0;?i???????neighbors.add(new?ArrayList());
????}
????for?(int?i?=?0;?i???????int?u?=?edges[i][0];
??????int?v?=?edges[i][1];
??????neighbors.get(u).add(v);
????}
??}
??/**?Create?adjacency?lists?for?each?vertex?*/
??private?void?createAdjacencyLists(
??????List?edges?int?numberOfVertices)?{
????//?Create?a?linked?list?for?each?vertex
????for?(int?i?=?0;?i???????neighbors.add(new?ArrayList());
????}
????for?(Edge?edge:?edges)?{
??????neighbors.get(edge.u).add(edge.v);
????}
??}
??/**?Return?the?number?of?vertices?in?the?graph?*/
??public?int?getSize()?{
????return?vertices.size();
??}
??/**?Return?the?vertices?in?the?graph?*/
??public?List?getVertices()?{
????return?vertices;
??}
??/**?Return?the?object?for?the?specified?vertex?*/
??public?V?getVertex(int?index)?{
????return?vertices.get(index);
??}
??/**?Return?the?index?for?the?specified?vertex?object?*/
??public?int?getIndex(V?v)?{
????return?vertices.indexOf(v);
??}
??/**?Return?the?neighbors?of?vertex?with?the?specified?index?*/
??public?List?getNeighbors(int?index)?{
????return?neighbors.get(index);
??}
??/**?Return?the?degree?for?a?specifie
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????226??2009-03-05?20:14??exercise\.classpath
?????文件????????384??2009-03-05?20:14??exercise\.project
?????文件????????421??2009-10-15?14:07??exercise\A.class
?????文件???????1496??2009-10-15?14:07??exercise\AbstractDrawFunction.class
?????文件????????429??2009-10-15?14:08??exercise\AbstractGraph$Edge.class
?????文件???????2849??2009-10-15?14:08??exercise\AbstractGraph$Tree.class
?????文件???????7060??2009-10-15?14:08??exercise\AbstractGraph.class
?????文件??????11644??2009-10-30?06:07??exercise\AbstractGraph.java
?????文件????????574??2009-10-15?14:08??exercise\AbstractTree.class
?????文件????????198??2007-05-02?08:28??exercise\AbstractTree.java
?????文件???????1509??2009-10-15?14:07??exercise\Account.class
?????文件???????2022??2009-10-15?14:07??exercise\Account1.class
?????文件???????1261??2009-10-15?14:07??exercise\Address.class
?????文件????????182??2004-12-14?20:23??exercise\address.dat
?????文件??????48072??1996-09-18?11:16??exercise\alarmSound.au
?????文件????????894??2009-10-15?14:07??exercise\ArcsPanel.class
?????文件??????12254??1999-02-26?14:03??exercise\audio\am.au
?????文件???????5598??1999-05-08?13:23??exercise\audio\anthem0.mid
?????文件???????7913??1999-05-08?13:21??exercise\audio\anthem1.mid
?????文件???????8342??1999-05-08?13:21??exercise\audio\anthem2.mid
?????文件???????3737??1999-05-08?13:31??exercise\audio\anthem3.mid
?????文件???????8332??1999-05-08?13:24??exercise\audio\anthem4.mid
?????文件???????5232??1999-05-08?13:22??exercise\audio\anthem5.mid
?????文件??????11000??1999-05-08?13:15??exercise\audio\anthem6.mid
?????文件???????8342??1999-05-08?13:21??exercise\audio\china.mid
?????文件???????5598??1999-05-08?13:23??exercise\audio\denmark.mid
?????文件???????7913??1999-05-08?13:21??exercise\audio\germany.mid
?????文件??????12254??1999-02-26?14:10??exercise\audio\hour0.au
?????文件??????12254??1999-02-26?14:04??exercise\audio\hour1.au
?????文件??????12254??1999-02-26?14:10??exercise\audio\hour10.au
............此處省略3250個文件信息
評論
共有 條評論