This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/jiaaro/pydub | |
from pydub import AudioSegment | |
files_path = '' | |
file_name = '' | |
startMin = 9 | |
startSec = 50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Topological_sort_with_cycle_check(adj): | |
visit = {x:0 for x in adj} | |
result = [] | |
def dfs_visit(node): | |
if visit[node] == -1: | |
return False | |
if visit[node] == 1: | |
return True | |
visit[node] = -1 | |
for neighbor in adj[node]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def DFS(adj): | |
def dfs_visit(node, result=None): | |
if result == None: | |
result = [] | |
for neighbor in adj[node]: | |
if neighbor not in seen: | |
result.append(neighbor) | |
seen.add(neighbor) | |
dfs_visit(neighbor, result) | |
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Topological_sort(adj): | |
result = [] | |
def dfs_visit(node): | |
for neighbor in adj[node]: | |
if neighbor not in seen: | |
seen.add(neighbor) | |
dfs_visit(neighbor) | |
result.insert(0, node) # insert to beginning of list | |
seen = set() | |
values = [] |