Are there any codes to generate planar graphs in matlab or are there any large collections of planar graphs in matlab?
6 ビュー (過去 30 日間)
古いコメントを表示
Are there any codes to generate planar graphs in matlab or are there any large collections of planar graphs in matlab? When posting codes if it's not obvious how to use the code to generate planar graphs an explanation would be helpful. (This is an modification to a previous question I posted)
1 件のコメント
Meb
2020 年 6 月 3 日
Hello Hao Sun,
Did you find the answer to your question? If so, please do share...would be helpful right now!
回答 (2 件)
Christine Tobler
2017 年 8 月 22 日
編集済み: Christine Tobler
2017 年 8 月 23 日
Can you give some more context on what kinds of planar graphs you are looking for? Are you trying to test an algorithm, maybe?
If you are just looking to generate a random planar graph, one way to do this is by leveraging the delaunay triangulation:
dt = delaunayTriangulation(randn(30, 2));
A = sparse(dt.ConnectivityList, dt.ConnectivityList(:, [2:end 1]), 1);
g = graph(A + A');
plot(g)
Note that the plot will probably show some edge intersections, because graph plot currently does not have a specialized layout for planar graphs. To verify that this is a planar graph, you can plot it using the coordinates of the vertices in the delaunay triangulation:
plot(g, 'XData', dt.Points(:, 1), 'YData', dt.Points(:, 2));
4 件のコメント
Standardtrickyness
2017 年 8 月 23 日
編集済み: Standardtrickyness
2017 年 8 月 23 日
Actually I've found your code can produce crossings
So the rows outputs the triangles abc with a,b,c points you gave to the delaunayTriangulation? I find the matlab page a bit confusing
Also what does [2: end l ] ?
Christine Tobler
2017 年 8 月 25 日
I'm sorry to hear that, could you show me an example?
The rows in dt.ConnectivityList contain the indexes of three points of the original data that form a triangle. The triangles in a triangulation are never meant to overlap, and so there should be no edges crossing.
Christine Tobler
2017 年 8 月 23 日
編集済み: Christine Tobler
2017 年 8 月 23 日
This is definitely the simplest way of generating random planar graphs in MATLAB, and should be reasonably quick (Delaunay triangulation is O(n * log(n)) in the number of input points). Googling for "random planar graph" finds some papers with custom algorithms that might be more suitable.
For purposes of testing, these random graphs might be too nicely behaved: All the faces are triangles, there are no articulation points, and the whole graph is connected. To get some more difficult-to-use planar graphs, you could simply remove a random subset of the edges generated by the previous method, which will give you more general polygonal faces, articulation points and separate components.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Delaunay Triangulation についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!