文件名称:Python 判断 有向图 是否有环的实例讲解
文件大小:33KB
文件格式:PDF
更新时间:2024-01-13 11:14:14
python 有向图
实例如下: import numpy from numpy import * def dfs( v ): vis[v] = -1 flag = 0 for i in range(n): # print (a[v][i],'---', vis[i] ) if a[v][i] != 0 and vis[i] != -1: dfs(i) vis[i] = 1 else: pass if a[v][i] != 0 and vis[i] == -1: print ('Yes, there is A loop in this network\n') global swi