Create codespell.yml (#1698)

* fixup! Format Python code with psf/black push

* Create codespell.yml

* fixup! Format Python code with psf/black push
This commit is contained in:
Christian Clauss
2020-01-18 13:24:33 +01:00
committed by GitHub
parent c01d178798
commit bfcb95b297
78 changed files with 206 additions and 188 deletions

View File

@@ -35,7 +35,7 @@ def search(grid, init, goal, cost, heuristic):
closed = [
[0 for col in range(len(grid[0]))] for row in range(len(grid))
] # the referrence grid
] # the reference grid
closed[init[0]][init[1]] = 1
action = [
[0 for col in range(len(grid[0]))] for row in range(len(grid))

View File

@@ -69,7 +69,7 @@ def dfs(G, s):
Args : G - Dictionary of edges
s - Starting Node
Vars : vis - Set of visited nodes
Q - Traveral Stack
Q - Traversal Stack
--------------------------------------------------------------------------------
"""
from collections import deque

View File

@@ -7,12 +7,12 @@ class Graph:
def __init__(self):
self.vertex = {}
# for printing the Graph vertexes
# for printing the Graph vertices
def printGraph(self):
for i in self.vertex.keys():
print(i, " -> ", " -> ".join([str(j) for j in self.vertex[i]]))
# for adding the edge beween two vertexes
# for adding the edge between two vertices
def addEdge(self, fromVertex, toVertex):
# check if vertex is already present,
if fromVertex in self.vertex.keys():
@@ -22,10 +22,10 @@ class Graph:
self.vertex[fromVertex] = [toVertex]
def BFS(self, startVertex):
# Take a list for stoting already visited vertexes
# Take a list for stoting already visited vertices
visited = [False] * len(self.vertex)
# create a list to store all the vertexes for BFS
# create a list to store all the vertices for BFS
queue = []
# mark the source node as visited and enqueue it

View File

@@ -7,13 +7,13 @@ class Graph:
def __init__(self):
self.vertex = {}
# for printing the Graph vertexes
# for printing the Graph vertices
def printGraph(self):
print(self.vertex)
for i in self.vertex.keys():
print(i, " -> ", " -> ".join([str(j) for j in self.vertex[i]]))
# for adding the edge beween two vertexes
# for adding the edge between two vertices
def addEdge(self, fromVertex, toVertex):
# check if vertex is already present,
if fromVertex in self.vertex.keys():
@@ -37,7 +37,7 @@ class Graph:
print(startVertex, end=" ")
# Recur for all the vertexes that are adjacent to this node
# Recur for all the vertices that are adjacent to this node
for i in self.vertex.keys():
if visited[i] == False:
self.DFSRec(i, visited)

View File

@@ -22,7 +22,7 @@ DIJKSTRA(graph G, start vertex s, destination vertex d):
13 - add (total_cost,V) to H
You can think at cost as a distance where Dijkstra finds the shortest distance
between vertexes s and v in a graph G. The use of a min heap as H guarantees
between vertices s and v in a graph G. The use of a min heap as H guarantees
that if a vertex has already been explored there will be no other path with
shortest distance, that happens because heapq.heappop will always return the
next vertex with the shortest distance, considering that the heap stores not
@@ -35,7 +35,7 @@ import heapq
def dijkstra(graph, start, end):
"""Return the cost of the shortest path between vertexes start and end.
"""Return the cost of the shortest path between vertices start and end.
>>> dijkstra(G, "E", "C")
6

View File

@@ -5,7 +5,7 @@
import math
import sys
# For storing the vertex set to retreive node with the lowest distance
# For storing the vertex set to retrieve node with the lowest distance
class PriorityQueue:
@@ -103,9 +103,7 @@ class Graph:
def show_graph(self):
# u -> v(w)
for u in self.adjList:
print(
u, "->", " -> ".join(str(f"{v}({w})") for v, w in self.adjList[u]),
)
print(u, "->", " -> ".join(str(f"{v}({w})") for v, w in self.adjList[u]))
def dijkstra(self, src):
# Flush old junk values in par[]

View File

@@ -3,7 +3,7 @@ import random as rand
import math as math
import time
# the dfault weight is 1 if not assigend but all the implementation is weighted
# the dfault weight is 1 if not assigned but all the implementation is weighted
class DirectedGraph:
@@ -12,7 +12,7 @@ class DirectedGraph:
# adding vertices and edges
# adding the weight is optional
# handels repetition
# handles repetition
def add_pair(self, u, v, w=1):
if self.graph.get(u):
if self.graph[u].count([w, v]) == 0:
@@ -25,14 +25,14 @@ class DirectedGraph:
def all_nodes(self):
return list(self.graph)
# handels if the input does not exist
# handles if the input does not exist
def remove_pair(self, u, v):
if self.graph.get(u):
for _ in self.graph[u]:
if _[1] == v:
self.graph[u].remove(_)
# if no destination is meant the defaut value is -1
# if no destination is meant the default value is -1
def dfs(self, s=-2, d=-1):
if s == d:
return []
@@ -71,7 +71,7 @@ class DirectedGraph:
if len(stack) == 0:
return visited
# c is the count of nodes you want and if you leave it or pass -1 to the funtion the count
# c is the count of nodes you want and if you leave it or pass -1 to the function the count
# will be random from 10 to 10000
def fill_graph_randomly(self, c=-1):
if c == -1:
@@ -271,7 +271,7 @@ class Graph:
# adding vertices and edges
# adding the weight is optional
# handels repetition
# handles repetition
def add_pair(self, u, v, w=1):
# check if the u exists
if self.graph.get(u):
@@ -290,7 +290,7 @@ class Graph:
# if u does not exist
self.graph[v] = [[w, u]]
# handels if the input does not exist
# handles if the input does not exist
def remove_pair(self, u, v):
if self.graph.get(u):
for _ in self.graph[u]:
@@ -302,7 +302,7 @@ class Graph:
if _[1] == u:
self.graph[v].remove(_)
# if no destination is meant the defaut value is -1
# if no destination is meant the default value is -1
def dfs(self, s=-2, d=-1):
if s == d:
return []
@@ -341,7 +341,7 @@ class Graph:
if len(stack) == 0:
return visited
# c is the count of nodes you want and if you leave it or pass -1 to the funtion the count
# c is the count of nodes you want and if you leave it or pass -1 to the function the count
# will be random from 10 to 10000
def fill_graph_randomly(self, c=-1):
if c == -1: