图库

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什么数据库最类似于Map,每个用户/id存储无限多个“键”和“值”?   java仅使用super pom进行测试   内存不足如何解析java。OutOfMemoryError:Java堆空间在增加堆大小的情况下将意味着延迟OutOfMemoryError   来自另一个类的mysql和java jdbc调用[运行时应用程序]   java通过下拉菜单更改搜索框搜索的内容   JAVAlang.ClassNotFoundException:sun。jdbc。odbc。JdbcOdbcDriver   java Selenium点击链接   JavaSpringHibernate:从唯一值列表中获取对象列表   java Bing广告与桌面身份验证问题   java如何在没有任何外部SDK的情况下从安卓打印到收据打印机?   未调用java菜单片段类   java在IDEA和PyCharm中同时为同一个项目工作   java我们如何为同一个异常提供不同的海关信息   jakarta ee中是否预定义了“请求”和“响应”变量或值?   java更好地解决“之前和之后”难题?   尝试将数据从Excel添加到Java   发送电子邮件的Java代码只适用于一个电子邮件id?   java如何从资产解析XML?