Passed
Push — master ( 669f3d...5fe484 )
by Xianshun
01:23
created

Graph.vertex_count()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 2
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 2
loc 2
rs 10
1
from pyalgs.data_structures.commons.bag import Bag
2
3
4 View Code Duplication
class Graph(object):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5
    V = 0
6
    adjList = None
7
8
    def __init__(self, V):
9
        self.V = V
10
        self.adjList = [Bag()] * V
11
12
    def vertex_count(self):
13
        return self.V
14
15
    def adj(self, v):
16
        return self.adjList[v].iterate()
17
18
    def add_edge(self, v, w):
19
        self.adjList[v].add(w)
20
        self.adjList[w].add(v)
21
22
23 View Code Duplication
class Digraph(object):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
24
    V = 0
25
    adjList = None
26
27
    def __init__(self, V):
28
        self.V = V
29
        self.adjList = [Bag()] * V
30
31
    def vertex_count(self):
32
        return self.V
33
34
    def adj(self, v):
35
        return self.adjList[v].iterate()
36
37
    def add_edge(self, v, w):
38
        self.adjList[v].add(w)
39
40
    def reverse(self):
41
        g = Digraph(self.V)
42
        for v in range(self.V):
43
            for w in self.adjList[v].iterate():
44
                g.add_edge(w, v)
45
46
        return g
47