| Total Complexity | 7 |
| Total Lines | 24 |
| Duplicated Lines | 100 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | from pyalgs.data_structures.commons.bag import Bag |
||
| 23 | View Code Duplication | class Digraph(object): |
|
| 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 |