<commit_before>Paths
=====

>>> import networkx as NX
>>> from networkx.operators import convert_node_labels_to_integers as cnlti
>>> G=cnlti(NX.grid_2d_graph(4,4),first_label=1,ordering="sorted")

    .. image:: paths_G.png

>>> H=NX.cycle_graph(7)
>>> DH=NX.cycle_graph(7,create_using=NX.DiGraph())

Paths and path lengths
----------------------

>>> NX.shortest_path_length(G,1,16)
6
>>> sp=NX.single_source_shortest_path_length(G,1)
>>> sp[16]
6
>>> NX.shortest_path(G,1,12)
[1, 2, 3, 4, 8, 12]

>>> NX.bidirectional_shortest_path(G,1,12)
[1, 2, 3, 4, 8, 12]

>>> sp=NX.single_source_shortest_path(G,1)
>>> sp[12] 
[1, 2, 3, 4, 8, 12]

>>> NX.shortest_path(H,0,3)
[0, 1, 2, 3]
>>> NX.shortest_path(H,0,4)
[0, 6, 5, 4]
>>> NX.bidirectional_shortest_path(H,0,3)
[0, 1, 2, 3]
>>> NX.bidirectional_shortest_path(H,0,4)
[0, 6, 5, 4]

>>> NX.shortest_path(DH,0,3)
[0, 1, 2, 3]
>>> NX.shortest_path(DH,0,4)
[0, 1, 2, 3, 4]
>>> NX.bidirectional_shortest_path(DH,0,3)
[0, 1, 2, 3]
>>> NX.bidirectional_shortest_path(DH,0,4)
[0, 1, 2, 3, 4]

Eccentricity, diameter, etc.
----------------------------

>>> NX.eccentricity(G,1)
6
>>> e=NX.eccentricity(G,with_labels=True)
>>> e[1]
6
>>> NX.diameter(G)
6
>>> NX.radius(G)
4
>>> NX.periphery(G)
[1, 4, 13, 16]
>>> NX.center(G)
[6, 7, 10, 11]

>>> G=NX.Graph()
>>> G.add_edge(1,2)
>>> G.add_edge(3,4)
>>> NX.diameter(G)
Traceback (most recent call last):
...
NetworkXError: Graph not connected: infinite path length
>>> NX.radius(G)
Traceback (most recent call last):
...
NetworkXError: Graph not connected: infinite path length
>>> NX.eccentricity(G)
Traceback (most recent call last):
...
NetworkXError: Graph not connected: infinite path length




Dijkstra
--------

>>> XG=NX.XDiGraph()
>>> XG.add_edges_from([('s','u',10) ,('s','x',5) ,('u','v',1) ,('u','x',2) ,('v','y',1) ,('x','u',3) ,('x','v',5) ,('x','y',2) ,('y','s',7) ,('y','v',6)])
>>> NX.draw(XG)
>>> import pylab as P
>>> P.savefig('test.png')
>>> (D,P)= NX.single_source_dijkstra(XG,'s')
>>> P['v']
['s', 'x', 'u', 'v']
>>> D['v']
9
>>> NX.single_source_dijkstra_path(XG,'s')['v']
['s', 'x', 'u', 'v']
>>> NX.single_source_dijkstra_path_length(XG,'s')['v']
9

>>> NX.single_source_dijkstra(XG,'s')[1]['v'] 
['s', 'x', 'u', 'v']

>>> GG=XG.to_undirected()<commit_msg>removed drawing of test graph - otherwise test wll fail if pylab is not available.<commit_after>Paths
=====

>>> import networkx as NX
>>> from networkx.operators import convert_node_labels_to_integers as cnlti
>>> G=cnlti(NX.grid_2d_graph(4,4),first_label=1,ordering="sorted")

    .. image:: paths_G.png

>>> H=NX.cycle_graph(7)
>>> DH=NX.cycle_graph(7,create_using=NX.DiGraph())

Paths and path lengths
----------------------

>>> NX.shortest_path_length(G,1,16)
6
>>> sp=NX.single_source_shortest_path_length(G,1)
>>> sp[16]
6
>>> NX.shortest_path(G,1,12)
[1, 2, 3, 4, 8, 12]

>>> NX.bidirectional_shortest_path(G,1,12)
[1, 2, 3, 4, 8, 12]

>>> sp=NX.single_source_shortest_path(G,1)
>>> sp[12] 
[1, 2, 3, 4, 8, 12]

>>> NX.shortest_path(H,0,3)
[0, 1, 2, 3]
>>> NX.shortest_path(H,0,4)
[0, 6, 5, 4]
>>> NX.bidirectional_shortest_path(H,0,3)
[0, 1, 2, 3]
>>> NX.bidirectional_shortest_path(H,0,4)
[0, 6, 5, 4]

>>> NX.shortest_path(DH,0,3)
[0, 1, 2, 3]
>>> NX.shortest_path(DH,0,4)
[0, 1, 2, 3, 4]
>>> NX.bidirectional_shortest_path(DH,0,3)
[0, 1, 2, 3]
>>> NX.bidirectional_shortest_path(DH,0,4)
[0, 1, 2, 3, 4]

Eccentricity, diameter, etc.
----------------------------

>>> NX.eccentricity(G,1)
6
>>> e=NX.eccentricity(G,with_labels=True)
>>> e[1]
6
>>> NX.diameter(G)
6
>>> NX.radius(G)
4
>>> NX.periphery(G)
[1, 4, 13, 16]
>>> NX.center(G)
[6, 7, 10, 11]

>>> G=NX.Graph()
>>> G.add_edge(1,2)
>>> G.add_edge(3,4)
>>> NX.diameter(G)
Traceback (most recent call last):
...
NetworkXError: Graph not connected: infinite path length
>>> NX.radius(G)
Traceback (most recent call last):
...
NetworkXError: Graph not connected: infinite path length
>>> NX.eccentricity(G)
Traceback (most recent call last):
...
NetworkXError: Graph not connected: infinite path length




Dijkstra
--------

>>> XG=NX.XDiGraph()
>>> XG.add_edges_from([('s','u',10) ,('s','x',5) ,('u','v',1) ,('u','x',2) ,('v','y',1) ,('x','u',3) ,('x','v',5) ,('x','y',2) ,('y','s',7) ,('y','v',6)])
>>> (D,P)= NX.single_source_dijkstra(XG,'s')
>>> P['v']
['s', 'x', 'u', 'v']
>>> D['v']
9
>>> NX.single_source_dijkstra_path(XG,'s')['v']
['s', 'x', 'u', 'v']
>>> NX.single_source_dijkstra_path_length(XG,'s')['v']
9

>>> NX.single_source_dijkstra(XG,'s')[1]['v'] 
['s', 'x', 'u', 'v']

>>> GG=XG.to_undirected()
{'fraction_non_alphanumeric': 0.28081740276862227, 'fraction_numerical': 0.057130301032740055, 'mean_word_length': 4.934810951760104, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 264, '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}}
{'dir': 'git-commits-cleaned', 'id': '2326033', 'n_tokens_mistral': 2297, 'n_tokens_neox': 2135, 'n_words': 392}