在 C 中获取图形数据结构输入的最佳方法?
我正在用 C 语言开发基本的图形实现(基于 Adj List),以便我可以重用基本结构来解决所有与图形相关的问题。
为了绘制我在纸上绘制的图表,我想要最好、最简单的方法。 谈论我接受输入的方式,而不是我应该如何实施它! :)
我是否应该创建一个输入例程,首先询问所有节点标签,然后询问基于两个标签连接的所有边?
有什么好的、快速的出路呢?我想要一种简单的方法,让我在“输入”上花费更少的精力。
I am working on a basic graph implementation(Adj List based) in C so that I can re-use the basic structure to solve all graph related problems.
To map a graph I draw on a paper,I want the best and easiest way.
Talking of the way I take the input rather then how should I go about implementing it! :)
Should I make an input routine which asks for all the nodes label first and then asks for what all edges are to be connected based on two labels?
What could be a good and quick way out? I want an easy way out which lets me spend less amount of energy on the "Input".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好是输入边缘列表,
即三元组,
源、目的地、成本
此例程可用于填充 Adj List 和 Adj Matrix。
对于后者,您需要正确初始化矩阵并设置约定来确定不存在的边。
Best is to go for input of an edge list,
that is triplets of,
Source, Destination, Cost
This routine can be used to fill Adj List and Adj Matrix.
With the latter, you would need to properly initialize the Matrix though and setup a convention to determine non existent edges.
在这里您可以找到有关图形表示的详细信息:
图内部表示
不过这里也给出了一些c++和java代码,您可以轻松地将它们转换为C代码。
Here you find details about representation of graph:
Graph-internal-representaion
However here some codes in c++ and java are also given,which you can easily convert to C codes.