<jupyter_start><jupyter_text>Check for Network Connectivity<jupyter_code>import os
import sys
from network_wrangler import RoadwayNetwork
%config IPCompleter.greedy=True

import logging
logger = logging.getLogger("WranglerLogger")
logger.handlers[0].stream = sys.stdout
# if you don't want to see so much detail, set to logging.INFO or DEBUG if you want to see everything
logger.setLevel(logging.INFO)
%load_ext autoreload
%autoreload 2<jupyter_output><empty_output><jupyter_text>SetupRead in Roadway Network<jupyter_code>STPAUL_DIR = os.path.join(os.path.dirname(os.getcwd()),'examples','stpaul')
STPAUL_SHAPE_FILE = os.path.join(STPAUL_DIR,"shape.geojson")
STPAUL_LINK_FILE = os.path.join(STPAUL_DIR,"link.json")
STPAUL_NODE_FILE = os.path.join(STPAUL_DIR,"node.geojson")
net = RoadwayNetwork.read(link_file= STPAUL_LINK_FILE, node_file=STPAUL_NODE_FILE, shape_file=STPAUL_SHAPE_FILE, fast=True)<jupyter_output><empty_output><jupyter_text>Connectivity CheckThe method `is_network_connected(mode = )` returns a Boolean True/False if every node is reachable from every other node for a given mode.<jupyter_code>net.is_network_connected(mode = "drive")
net.is_network_connected(mode = "walk")
net.is_network_connected(mode = "bike")<jupyter_output><empty_output><jupyter_text>Assessing ConnectivityIf the network is not connected, you will want to learn more to make sure nothing is amiss. - `assess_connectivity()` returns a tuple of the network Graph and list of subgraphs as described by their nodes.  - `network_connection_plot()` returns an matplotlib fig, ax tuple<jupyter_code>bike_G, disconnected_bike_nodes = net.assess_connectivity(mode="bike")
fig, ax = net.network_connection_plot(bike_G, disconnected_bike_nodes)
fig
drive_G, disconnected_drive_nodes = net.assess_connectivity(mode="drive")
fig, ax = net.network_connection_plot(drive_G, disconnected_drive_nodes)
fig
walk_G, disconnected_walk_nodes = net.assess_connectivity(mode="walk")
fig, ax = net.network_connection_plot(walk_G, disconnected_walk_nodes)
fig<jupyter_output><empty_output><jupyter_text>Note that `assess_connectivity()` takes an additional boolean keyword: `ignore_end_nodes` which defaults to True.  When set to True, the method will ignore singleton nodes.<jupyter_code>drive_G_2, disconnected_drive_nodes_2 = net.assess_connectivity(mode="drive", ignore_end_nodes = False)
fig, ax = net.network_connection_plot(drive_G_2, disconnected_drive_nodes_2)
fig<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09315512353179425, 'fraction_numerical': 0.002430133657351154, 'mean_word_length': 8.88, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '528218', 'license': 'Apache-2.0', 'n_tokens_mistral': 838, 'n_tokens_neox': 816, 'n_words': 181, 'path': 'notebook/Validation - Network Connectivity.ipynb', 'repo_name': 'BayAreaMetro/network_wrangler', 'size': '2469'}