Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes remove disconnected from bool to int for more control #103

Merged
merged 7 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/plots/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
buffer = 1250
poly_wgs, _poly_utm, _utm_zone_number, _utm_zone_letter = io.buffered_point_poly(lng, lat, buffer)
graph_raw = io.osm_graph_from_poly(poly_wgs, simplify=False)
graph_utm = io.osm_graph_from_poly(poly_wgs, simplify=True, remove_parallel=True, iron_edges=True)
graph_utm = io.osm_graph_from_poly(poly_wgs, simplify=True, iron_edges=True)
# plot buffer
easting, northing = utm.from_latlon(lat, lng)[:2]
buff = geometry.Point(easting, northing).buffer(750)
Expand Down Expand Up @@ -126,7 +126,7 @@ def simple_plot(_G, _path, plot_geoms=True):

graph_utm = graphs.nx_simple_geoms(graph_raw)
graph_utm = graphs.nx_remove_filler_nodes(graph_utm)
graph_utm = graphs.nx_remove_dangling_nodes(graph_utm, despine=15, remove_disconnected=True)
graph_utm = graphs.nx_remove_dangling_nodes(graph_utm, despine=15, remove_disconnected=10)
simple_plot(graph_utm, f"{IMAGES_PATH}/graph_cleaning_2.{FORMAT}")
# first pass of consolidation
graph_utm = graphs.nx_consolidate_nodes(graph_utm, buffer_dist=15, crawl=True)
Expand Down
Binary file modified docs/public/images/assignment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/assignment_decomposed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/assignment_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/betas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph_cleaning_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph_cleaning_1b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph_cleaning_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph_cleaning_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph_cleaning_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph_cleaning_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph_cleaning_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph_colour.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph_decomposed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph_dual.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/graph_simple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/intro_mixed_uses.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/images/intro_segment_harmonic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 13 additions & 12 deletions docs/src/pages/metrics/networks.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ This effect is amplified for denser regions of the network.
- Segmentised versions of centrality measures should not be computed on dual graph topologies because street segment
lengths would be duplicated for each permutation of dual edge spanning street intersections. By way of example,
the contribution of a single edge segment at a four-way intersection would be duplicated three times.
- Global closeness is strongly discouraged because it does not behave suitably for localised graphs. Harmonic
closeness should be used instead.
- The usual formulations of closeness or normalised closeness are discouraged because these do not behave
suitably for localised graphs. Harmonic closeness or Hillier normalisation (which resembles a simplified form of
Improved Closeness Centrality proposed by Wasserman and Faust) should be used instead.
- Network decomposition can be a useful strategy when working at small distance thresholds, and confers advantages
such as more regularly spaced snapshots and fewer artefacts at small distance thresholds where street edges
intersect distance thresholds. However, the regular spacing of the decomposed segments will introduce spikes in the
Expand Down Expand Up @@ -110,9 +111,7 @@ may therefore be preferable when working at small thresholds on decomposed netwo
Compute node-based network centrality using the shortest path heuristic.
:::note
Node weights are taken into account when computing centralities. These would typically be initialised at 1 unless
manually specified. Consider use of
[`graphs.nx_weight_by_dissolved_edges`](/tools/graphs#nx-weight-by-dissolved-edges) when working with complex
network representations.
manually specified.
:::
### Parameters
<div class="param-set">
Expand Down Expand Up @@ -213,10 +212,11 @@ network representations.
| key | formula | notes |
| ----------------------| :------:| ----- |
| node_density | $$\sum_{j\neq{i}}^{n}1$$ | A summation of nodes. |
| node_farness | $$\sum_{j\neq{i}}^{n}d_{(i,j)}$$ | A summation of distances in metres. |
| node_cycles | $$\sum_{j\neq{i}j=cycle}^{n}1$$ | A summation of network cycles. |
| node_harmonic | $$\sum_{j\neq{i}}^{n}\frac{1}{Z_{(i,j)}}$$ | Harmonic closeness is an appropriate form of closeness centrality for localised implementations constrained by the threshold $d_{max}$. |
| node_harmonic | $$\sum_{j\neq{i}}^{n}\frac{1}{d_{(i,j)}}$$ | Harmonic closeness is an appropriate form of closeness centrality for localised implementations constrained by the threshold $d_{max}$. |
| node_hillier | $$\frac{(n-1)^2}{\sum_{j \neq i}^{n} d_{(i,j)}}$$ | The square of node density divided by farness. This is also a simplified form of Improved Closeness Centrality. |
| node_beta | $$\sum_{j\neq{i}}^{n} \\ \exp(-\beta\cdot d[i,j])$$ | Also known as the gravity index. This is a spatial impedance metric differentiated from other closeness centralities by the use of an explicit $\beta$ parameter, which can be used to model the decay in walking tolerance as distances increase. |
| node_cycles | $$\sum_{j\neq{i}j=cycle}^{n}1$$ | A summation of network cycles. |
| node_farness | $$\sum_{j\neq{i}}^{n}d_{(i,j)}$$ | A summation of distances in metres. |
| node_betweenness | $$\sum_{j\neq{i}}^{n}\sum_{k\neq{j}\neq{i}}^{n}1$$ | Betweenness centrality summing all shortest-paths traversing each node $i$. |
| node_betweenness_beta | $$\sum_{j\neq{i}}^{n}\sum_{k\neq{j}\neq{i}}^{n} \\ \exp(-\beta\cdot d[j,k])$$ | Applies a spatial impedance decay function to betweenness centrality. $d$ represents the full distance from any $j$ to $k$ node pair passing through node $i$. |

Expand Down Expand Up @@ -281,9 +281,7 @@ network representations.
Compute node-based network centrality using the simplest path (angular) heuristic.
:::note
Node weights are taken into account when computing centralities. These would typically be initialised at 1 unless
manually specified. Consider use of
[`graphs.nx_weight_by_dissolved_edges`](/tools/graphs#nx-weight-by-dissolved-edges) when working with complex
network representations.
manually specified.
:::
### Parameters
<div class="param-set">
Expand Down Expand Up @@ -383,7 +381,10 @@ network representations.

| key | formula | notes |
| ----------------------| :------:| ----- |
| node_harmonic_simplest | $$\sum_{j\neq{i}}^{n}\frac{1}{Z_{(i,j)}}$$ | Harmonic closeness is an appropriate form of closeness centrality for localised implementations constrained by the threshold $d_{max}$. |
| node_density_simplest | $$\sum_{j\neq{i}}^{n}1$$ | A summation of nodes. |
| node_harmonic_simplest | $$\sum_{j\neq{i}}^{n}\frac{1}{d_{(i,j)}}$$ | Harmonic closeness is an appropriate form of closeness centrality for localised implementations constrained by the threshold $d_{max}$. |
| node_hillier_simplest | $$\frac{(n-1)^2}{\sum_{j \neq i}^{n} d_{(i,j)}}$$ | The square of node density divided by farness. This is also a simplified form of Improved Closeness Centrality. |
| node_farness_simplest | $$\sum_{j\neq{i}}^{n}d_{(i,j)}$$ | A summation of distances in metres. |
| node_betweenness_simplest | $$\sum_{j\neq{i}}^{n}\sum_{k\neq{j}\neq{i}}^{n}1$$ | Betweenness centrality summing all shortest-paths traversing each node $i$. |

The following keys use the simplest-path (shortest-angular-path) heuristic, and are available when the `angular` parameter is explicitly set to `True`:
Expand Down
8 changes: 4 additions & 4 deletions docs/src/pages/rustalgos/rustalgos.md
Original file line number Diff line number Diff line change
Expand Up @@ -2726,22 +2726,22 @@ datapoints are not located with high spatial precision.



<span class="name">node_xs</span><span class="annotation">: list[float]</span>
<span class="name">node_lives</span><span class="annotation">: list[bool]</span>




<span class="name">node_xys</span><span class="annotation">: list[tuple[float, float]]</span>
<span class="name">node_ys</span><span class="annotation">: list[float]</span>




<span class="name">node_lives</span><span class="annotation">: list[bool]</span>
<span class="name">node_xys</span><span class="annotation">: list[tuple[float, float]]</span>




<span class="name">node_ys</span><span class="annotation">: list[float]</span>
<span class="name">node_xs</span><span class="annotation">: list[float]</span>



Expand Down
6 changes: 3 additions & 3 deletions docs/src/pages/tools/graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ side-effects as a function of varied node intensities when computing network cen
<div class="param">
<span class="pn">remove_disconnected</span>
<span class="pc">:</span>
<span class="pa"> bool = True</span>
<span class="pa"> int = 100</span>
</div>
<div class="param">
<span class="pn">cleanup_filler_nodes</span>
Expand Down Expand Up @@ -158,11 +158,11 @@ side-effects as a function of varied node intensities when computing network cen
<div class="param-set">
<div class="def">
<div class="name">remove_disconnected</div>
<div class="type">bool</div>
<div class="type">int</div>
</div>
<div class="desc">

Whether to remove disconnected components. If set to `True`, only the largest connected component will be returned. Defaults to True.</div>
Remove disconnected components with fewer nodes than specified by this parameter. Defaults to 100. Set to 0 to keep all disconnected components.</div>
</div>

<div class="param-set">
Expand Down
15 changes: 15 additions & 0 deletions docs/src/pages/tools/io.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@ builds a graph automatically.
<span class="pc">:</span>
<span class="pa"> bool = True</span>
</div>
<div class="param">
<span class="pn">remove_disconnected</span>
<span class="pc">:</span>
<span class="pa"> int = 100</span>
</div>
<div class="param">
<span class="pn">timeout</span>
<span class="pc">:</span>
Expand Down Expand Up @@ -512,6 +517,16 @@ builds a graph automatically.
Whether to iron the edges.</div>
</div>

<div class="param-set">
<div class="def">
<div class="name">remove_disconnected</div>
<div class="type">int</div>
</div>
<div class="desc">

Remove disconnected components containing fewer nodes than specified. 100 nodes by default.</div>
</div>

<div class="param-set">
<div class="def">
<div class="name">timeout</div>
Expand Down
45 changes: 25 additions & 20 deletions docs/src/pages/tools/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,9 @@ layout: ../../layouts/PageLayout.astro
<span class="pt">(</span>
<div class="param">
<span class="pn">linestring_coords_a</span>
<span class="pc">:</span>
<span class="pa"> list[typing.Union[tuple[float, float], tuple[float, float, float]]]</span>
</div>
<div class="param">
<span class="pn">linestring_coords_b</span>
<span class="pc">:</span>
<span class="pa"> list[typing.Union[tuple[float, float], tuple[float, float, float]]]</span>
</div>
<span class="pt">)</span>
</div>
Expand All @@ -102,8 +98,6 @@ layout: ../../layouts/PageLayout.astro
<span class="pt">(</span>
<div class="param">
<span class="pn">linestring_coords</span>
<span class="pc">:</span>
<span class="pa"> list[typing.Union[tuple[float, float], tuple[float, float, float]]]</span>
</div>
<span class="pt">)-&gt;[</span>
<span class="pr">float</span>
Expand All @@ -127,8 +121,6 @@ layout: ../../layouts/PageLayout.astro
<span class="pt">(</span>
<div class="param">
<span class="pn">linestring_coords</span>
<span class="pc">:</span>
<span class="pa"> list[typing.Union[tuple[float, float], tuple[float, float, float]]]</span>
</div>
<span class="pt">)-&gt;[</span>
<span class="pr">float</span>
Expand Down Expand Up @@ -157,11 +149,14 @@ layout: ../../layouts/PageLayout.astro
<span class="pn">x_y</span>
</div>
<span class="pt">)-&gt;[</span>
<span class="pr">Union[tuple[float</span>
<span class="pr">Union[list[Union[tuple[float</span>
<span class="pr">float]</span>
<span class="pr">tuple[float</span>
<span class="pr">float</span>
<span class="pr">float</span>
<span class="pr">float]</span>
<span class="pr">ndarray[Any</span>
<span class="pr">float64]]]]</span>
<span class="pr">CoordinateSequence</span>
<span class="pt">]</span>
</div>
</div>
Expand Down Expand Up @@ -219,11 +214,14 @@ layout: ../../layouts/PageLayout.astro
<span class="pn">x_y</span>
</div>
<span class="pt">)-&gt;[</span>
<span class="pr">Union[tuple[float</span>
<span class="pr">Union[list[Union[tuple[float</span>
<span class="pr">float]</span>
<span class="pr">tuple[float</span>
<span class="pr">float</span>
<span class="pr">float</span>
<span class="pr">float]</span>
<span class="pr">ndarray[Any</span>
<span class="pr">float64]]]]</span>
<span class="pr">CoordinateSequence</span>
<span class="pt">]</span>
</div>
</div>
Expand Down Expand Up @@ -291,11 +289,14 @@ layout: ../../layouts/PageLayout.astro
<span class="pa"> float = 0.5</span>
</div>
<span class="pt">)-&gt;[</span>
<span class="pr">Union[tuple[float</span>
<span class="pr">Union[list[Union[tuple[float</span>
<span class="pr">float]</span>
<span class="pr">tuple[float</span>
<span class="pr">float</span>
<span class="pr">float</span>
<span class="pr">float]</span>
<span class="pr">ndarray[Any</span>
<span class="pr">float64]]]]</span>
<span class="pr">CoordinateSequence</span>
<span class="pt">]</span>
</div>
</div>
Expand Down Expand Up @@ -383,20 +384,21 @@ layout: ../../layouts/PageLayout.astro
</div>
<div class="param">
<span class="pn">linestring_coords</span>
<span class="pc">:</span>
<span class="pa"> list[typing.Union[tuple[float, float], tuple[float, float, float]]]</span>
</div>
<div class="param">
<span class="pn">tolerance</span>
<span class="pc">:</span>
<span class="pa"> float = 0.5</span>
</div>
<span class="pt">)-&gt;[</span>
<span class="pr">Union[tuple[float</span>
<span class="pr">Union[list[Union[tuple[float</span>
<span class="pr">float]</span>
<span class="pr">tuple[float</span>
<span class="pr">float</span>
<span class="pr">float</span>
<span class="pr">float]</span>
<span class="pr">ndarray[Any</span>
<span class="pr">float64]]]]</span>
<span class="pr">CoordinateSequence</span>
<span class="pt">]</span>
</div>
</div>
Expand Down Expand Up @@ -492,11 +494,14 @@ layout: ../../layouts/PageLayout.astro
<span class="pa"> float = 0.01</span>
</div>
<span class="pt">)-&gt;[</span>
<span class="pr">Union[tuple[float</span>
<span class="pr">Union[list[Union[tuple[float</span>
<span class="pr">float]</span>
<span class="pr">tuple[float</span>
<span class="pr">float</span>
<span class="pr">float</span>
<span class="pr">float]</span>
<span class="pr">ndarray[Any</span>
<span class="pr">float64]]]]</span>
<span class="pr">CoordinateSequence</span>
<span class="pt">]</span>
</div>
</div>
Expand Down
Loading
Loading