File tree Expand file tree Collapse file tree 1 file changed +15
-14
lines changed
Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change 11package
22 Graph ;
33
4- import java .util .LinkedList ;
4+ import java . util .LinkedList ;
55
66
77public class Graph {
88
99 private final int V ;private int E ;
1010 private LinkedList <Integer >[] adj ;
1111
12- public Graph (int V )
12+ public Graph (int V )
1313 {
1414 this .V =V ;
1515 this .E =0 ;
1616 adj = (LinkedList <Integer >[ ]) new LinkedList [ V ];
1717 for (int v =0 ; v < V ; v ++)
18- adj [v ] = new LinkedList <>();
18+ adj [v ] = new LinkedList < >();
1919 }
2020
21- public int V ( )
22- {
21+ public int V ( )
22+ {
2323
2424
2525
26- return V ;
27- }
26+ return V ;
27+ }
2828
2929 public
3030 int E () {
31- return E ;
31+ return E ;
3232 }
3333
3434 public void addEdge (int v , int w ) {
35- adj [v ].add ( w );
35+ adj [v ].add ( w );
3636 adj [w ].add (v );
3737 E ++ ;
3838 }
3939
4040 public LinkedList < Integer > adj (int v ) {
41- return adj [v ];
41+ return adj [v ]
42+ ;
4243 }
4344
4445 public int degree ( int v ,Graph g ) {
45- int count = 0 ;
46- for (int s : adj (v ) )
47- count ++;
48- return count ;
46+ int count = 0 ;
47+ for (int s : adj (v ) )
48+ count ++ ;
49+ return count ;
4950 }
5051
5152}
You can’t perform that action at this time.
0 commit comments