spatialgraph2D

Version 2.1.0 (3.82 KB) by Matt J
Creates a graph object with 2D spatial locations associated with the nodes
221 Downloads
Updated Sat, 06 Jan 2024 17:05:15 +0000

View License

This submission defines a graph class which allows 2D (x,y) location data to be attached to the nodes. It was designed with mosaic graphs in mind. By a mosaic graph, I mean a graph in which distinct edges may intersect one another only at the nodes. Currently, its main capability is decomposing a mosaic graph into its constituent polygons. As an example, given the graph,
s = [1 1 1 2 3 3 4 4 5 6 7 6 8 9 10 10 12 12 13 14 15 16 17 17 18 19 20 21 20 25];
t = [2 8 18 3 4 23 5 21 6 7 8 11 9 10 11 12 14 13 15 18 16 17 18 25 19 20 1 22 24 26];
G = graph(s,t);
we associate the nodes of G to the following x, y data,
x = [0.5 0 0 0 0.5 1 1.5 2 3 3 3 5.5 6 4 6 6 4 3 2 0.5 -1 -2 -1 1.5 4.5 4.5];
y = [0 0.5 1 1.5 2 2 1.5 1 1 1.5 2 1 0.5 0.5 0 -1 -1 -0.5 -1 -1 1 0.5 0.5 -0.5 -0.5 0];
We create a spatialgraph2D object as follows,
obj=spatialgraph2D(G,x,y);
Then, we can obtain a polyshape array of all the constituent polygons by doing,
pgon=polyshape(obj);
Or, obtain the node sequences demarcating each polygon with the syntax,
[~,nodeSequences]=polyshape(obj);
To visualize the decomposition, the class has several plotting methods. The following was used to generate the image thumbnail above.
mosaic(obj);

Cite As

Matt J (2024). spatialgraph2D (https://www.mathworks.com/matlabcentral/fileexchange/73630-spatialgraph2d), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2018a
Compatible with R2016b and later releases
Platform Compatibility
Windows macOS Linux
Categories
Find more on Directed Graphs in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
2.1.0

Added support for directed graphs

2.0.7

Description update

2.0.6

Description update

2.0.5

The polyshape() method now returns an empty polyshape and labelIndices cell as outputs when no mosaic polygons exist in the graph.

2.0.4

Bug fix dealing with graphs with no polygons present.

2.0.3

Description update

2.0.2

Added support for abbreviated syntaxes spatialgraph2D(G) and spatialgraph2D(G,[[,[],labels)

2.0.1

Minor change which should improve efficiency slightly.

2.0

Removed restriction on multiple mosaics in polyshape() method. All polygons in the graph should now be found, regardless of how they are interconnected.

1.0.4

Edit

1.0.3

Description edit

1.0.2

Description edit

1.0.1

Description edit

1.0.0