-
大小: 3.85MB文件類型: .rar金幣: 2下載: 0 次發布日期: 2023-10-01
- 語言: Java
- 標簽: ntroduction??to??Java??Programming??
資源簡介
Introduction to Java Programming第八版的原碼+習題代碼,作者Y.daniel Liang

代碼片段和文件信息
import?java.util.*;
public?abstract?class?AbstractGraph?implements?Graph?{
??protected?List?vertices;?//?Store?vertices
??protected?List>?neighbors;?//?Adjacency?lists
??/**?Construct?a?graph?from?edges?and?vertices?stored?in?arrays?*/
??protected?AbstractGraph(int[][]?edges?V[]?vertices)?{
????this.vertices?=?new?ArrayList();
????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)?{
????this.vertices?=?vertices;
????createAdjacencyLists(edges?vertices.size());
??}
??/**?Construct?a?graph?for?integer?vertices?0?1?2?and?edge?list?*/
??protected?AbstractGraph(List?edges?int?numberOfVertices)?{
????vertices?=?new?ArrayList();?//?Create?vertices
????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)?{
????vertices?=?new?ArrayList();?//?Create?vertices
????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
????neighbors?=?new?ArrayList>();
????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
????neighbors?=?new?ArrayList>();
????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);
??}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????631??2009-10-15?14:06??Introduction?to?Java?Programming\book\A.class
?????文件????????429??2009-10-15?14:06??Introduction?to?Java?Programming\book\AbstractGraph$Edge.class
?????文件???????2849??2009-10-15?14:06??Introduction?to?Java?Programming\book\AbstractGraph$Tree.class
?????文件???????8825??2009-10-15?14:06??Introduction?to?Java?Programming\book\AbstractGraph.class
?????文件??????12435??2009-04-18?10:32??Introduction?to?Java?Programming\book\AbstractGraph.java
?????文件????????944??2009-10-15?14:06??Introduction?to?Java?Programming\book\AbstractTree.class
?????文件????????558??2007-05-13?20:44??Introduction?to?Java?Programming\book\AbstractTree.java
?????文件????????869??2009-10-15?14:06??Introduction?to?Java?Programming\book\AccountWithoutSync$Account.class
?????文件????????705??2009-10-15?14:06??Introduction?to?Java?Programming\book\AccountWithoutSync$AddAPennyTask.class
?????文件???????1636??2009-10-15?14:06??Introduction?to?Java?Programming\book\AccountWithoutSync.class
?????文件???????1239??2007-05-14?06:32??Introduction?to?Java?Programming\book\AccountWithoutSync.java
?????文件???????1142??2009-10-15?14:06??Introduction?to?Java?Programming\book\AccountWithSyncUsingLock$Account.class
?????文件????????645??2009-10-15?14:06??Introduction?to?Java?Programming\book\AccountWithSyncUsingLock$AddAPennyTask.class
?????文件???????1593??2009-10-15?14:06??Introduction?to?Java?Programming\book\AccountWithSyncUsingLock.class
?????文件???????1472??2007-05-14?06:32??Introduction?to?Java?Programming\book\AccountWithSyncUsingLock.java
?????文件???????1770??2009-10-15?14:06??Introduction?to?Java?Programming\book\ActionInterfaceDemo$MyAction.class
?????文件???????4144??2009-10-15?14:06??Introduction?to?Java?Programming\book\ActionInterfaceDemo.class
?????文件???????3821??2007-05-14?13:32??Introduction?to?Java?Programming\book\ActionInterfaceDemo.java
?????文件????????744??2009-10-15?14:06??Introduction?to?Java?Programming\book\AdapterDemo$1.class
?????文件????????839??2009-10-15?14:06??Introduction?to?Java?Programming\book\AdapterDemo.class
?????文件????????609??2007-05-13?09:22??Introduction?to?Java?Programming\book\AdapterDemo.java
?????文件???????1413??2009-10-15?14:06??Introduction?to?Java?Programming\book\AdditionQuiz.class
?????文件????????548??2007-10-05?22:09??Introduction?to?Java?Programming\book\AdditionQuiz.java
?????文件???????1252??2009-10-15?14:06??Introduction?to?Java?Programming\book\Address.class
?????文件??????????0??2006-12-29?19:09??Introduction?to?Java?Programming\book\address.dat
?????文件????????823??2007-05-13?08:13??Introduction?to?Java?Programming\book\Address.java
?????文件????????636??2009-10-15?14:06??Introduction?to?Java?Programming\book\AddressBook$1.class
?????文件????????924??2009-10-15?14:06??Introduction?to?Java?Programming\book\AddressBook$2.class
?????文件???????1049??2009-10-15?14:06??Introduction?to?Java?Programming\book\AddressBook$3.class
?????文件???????1063??2009-10-15?14:06??Introduction?to?Java?Programming\book\AddressBook$4.class
............此處省略1392個文件信息
評論
共有 條評論