File Exchange

image thumbnail

spatialgraph2D

version 1.0.4 (2.34 KB) by Matt J
Creates a graph object with 2D spatial locations associated with the nodes

4 Downloads

Updated 09 Dec 2019

View License

This submission defines a graph class which allows 2D (x,y) location data to be attached to the nodes. It is useful for studying and manipulating mosaics of polygons. Currently, its main capability is analyzing a graph and determining the constituent polygons that it consists of. 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 as follows,

pgon=polyshape(obj);

To visualize, use the following pair of overlaid plots. This was used to generate the image thumbnail above.

plot(obj);
hold on
plot(pgon);
hold off

Note that currently, graphs containing multiple connected or disconnected mosaics are outside the scope of what the class code will analyze. Extra dangling branches, in particular, are not treated as part of the main mosaic, as the above plot shows.

Cite As

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

Comments and Ratings (0)

Updates

1.0.4

Edit

1.0.3

Description edit

1.0.2

Description edit

1.0.1

Description edit

MATLAB Release Compatibility
Created with R2018a
Compatible with R2016b to any release
Platform Compatibility
Windows macOS Linux