图库

graph-theor的Python项目详细描述


图表

一个简单的图形库…
…有点像networkx,只是没有开销…
…类似于Graph工具,没有Python2.7遗留版本…


import Graph
g = Graph()

就这样。


可用方法:

methodsdescription
^{}assert if g contains node a
^{}adds a node (with a pointer to object ^{} if given)
^{}returns object attached to node 1.
^{}deletes node1 and all it's edges.
^{}returns a list of nodes
^{}returns the number of nodes
^{}returns nodes with edges from node 1
^{}returns nodes with edges to node 2
^{}returns nodes with 2 incoming edges
^{}returns nodes with 2 outgoing edges
^{}adds edge to g for vector ^{} with value ^{}
^{}returns value of edge between nodes 1 and 2
^{}returns ^{} if ^{} doesn't exist.
similar to ^{}
^{}removes edge between nodes 1 and 2
^{}returns a list of edges (along a path if given).
^{}returns edges outgoing from node 1
^{}returns edges incoming to node 2
^{}returns the number of edges
^{}updates the graph from a dictionary
^{}dumps the graph as a dictionary
^{}updates the graph from a list
^{}dumps the graph as a list of edges
^{}finds the path with smallest edge sum
^{}finds the with least number of hops
^{}finds a path between 2 nodes (start, end) using DFS and backtracking.
^{}finds the distance following a given path.
^{}finds the maximum flow between a source and a sink
^{}solves the traveling salesman problem for the graph
^{}determines if graph ^{} is a subgraph in g.
^{}determines if graph is n-partite
^{}determines if there are cycles in the graph
^{}compares two paths, returns True if they're the same.
^{}constructs the adjacency matrix for the graph.
^{}finds the shortest path between all nodes.
^{}finds the shortest tree for all pairs.
^{}asserts whether a path ^{} exists in g.
^{}finds all combinations of paths between 2 nodes.

常见问题解答

want todoesn't workdo insteadbut why?
have multiple edges between two nodes^{}Add dummy nodes
^{}
^{}
Explicit is better than implicit.
multiple values on an edge^{}Have two graphs
^{}
^{}
Most graph algorithms don't work with multiple values

示例

示例包含了一些常见操作研究的教程/解决方案 以及计算机科学问题,当把它们当作一个图来处理时就变得简单了。

modulefunctiondescription
assignment_problem.pyassignment_problemsolves the assignment problem
hashgraph.pymerkle_treedatablocks
hashgraph.pygraph_hashcomputes the sha256 of a graphs nodes and edges
hashgraph.pyflow_graph_hashcomputes the sha256 of a graph with multiple sources and sinks
knapsack_problem.pyknapsack problemsolves the knapsack problem
wtap.pyweapons-target assignment problemsolves the WTAP problem.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Intellij通过方法中的包查找用法   java中VS代码和打包命名的问题   将java CMS功能集成到具有高度动态内容的网站(Lucene/Mysql/Nosql)的策略   oracle的java类强制转换异常。jdbc。驾驶员OracleConnection   字节码向JVM添加上指令   如何在抽象类中执行java方法?   java是否可以在apache访问日志中排除指定的GET参数?(作者:W7开发环境)   java如何获取已安装音频播放器的列表?   尝试向HS学生展示如何使用Java访问MS数据库   使用正则表达式java对给定行中的特定字符串进行计数   java JOOQ Select查询中的Select计数   方法Java,如何从二维双精度数组中找到特定值?   获取图像URL的java正则表达式   java在切换到新的窗口驱动程序后找不到元素