
    <iњ                         S SK r S SKrS SKrS SKrS SKrS SKJr  S SKrS SKr	S SK
Jr  S SKJrJr  SSKJr  SSKJr  SSKJrJr  SS	KJr   " S
 S\5      rg)    N)defaultdict)IFrame)EnvironmentFileSystemLoader   )Edge)Node)Options	Configure)
check_htmlc                      \ rS rSrSr            S2S jrS rS rS3S jrS	 r	S
 r
S rS rS rS rS rS4S jrS5S jrS6S jr S7S jrS\4S jrS8S jrS rS rS rS S SSSS4S jrS  rS! rS" r      S9S# jr     S:S$ jr     S;S% jr       S<S& jr!S=S' jr"S( r#S) r$S* r%S+ r&S>S, jr'S- r(S. r)S/ r*S0 r+S1r,g)?Network   z
The Network class is the focus of this library. All viz functionality
should be implemented off of a Network instance.

To instantiate:

>>> nt = Network()
FNc                 T   / U l         / U l        Xl        X l        Xl        SU l        SU l        Xl        X0l        Xl	        SU l
        SU l        [        U
5      U l        SU l        / U l        0 U l        SU l        SU l        XPl        X`l        Xpl        US;   d   S5       eSU l        [.        R,                  R1                  [2        5      S-   U l        [7        [9        U R4                  5      S	9U l        US
:X  a  US:X  a  [=        S5        Xl        U(       a  U RA                  5         gg)a  
:param height: The height of the canvas
:param width: The width of the canvas
:param directed: Whether or not to use a directed graph. This is false
                 by default.
:param notebook: True if using jupyter notebook.
:param select_menu: sets the option to highlight nodes and the neighborhood
:param filter_menu: sets the option to filter nodes and edges based on attributes
:param bgcolor: The background color of the canvas.
:param cdn_resources: Where to pull resources for css and js files. Defaults to local.
    Options ['local','in_line','remote'].
    local: pull resources from local lib folder.
    in_line: insert lib resources as inline script tags.
    remote: pull resources from hash checked cdns.
:font_color: The color of the node labels text
:layout: Use hierarchical layout if this is set

:type height: num or str
:type width: num or str
:type directed: bool
:type notebook: bool
:type select_menu: bool
:type filter_menu: bool
:type bgcolor: str
:type font_color: str
:type layout: bool
:type cdn_resources: str
 dotFN)localin_lineremotez.cdn_resources not in [local, in_line, remote].template.htmlz/templates/loaderr   TzWarning: When  cdn_resources is 'local' jupyter notebook has issues displaying graphics on chrome/safari. Use cdn_resources='in_line' or cdn_resources='remote' if you have issues viewing graphics in a notebook.)!nodesedgesheightwidthheadinghtmlshape
font_colordirectedbgcoloruse_DOTdot_langr
   optionswidgetnode_idsnode_maptemplateconfneighborhood_highlightselect_menufilter_menupathosdirname__file__template_dirr   r   templateEnvprintcdn_resourcesprep_notebook)selfr   r   r!   notebookr+   r,   r-   r"   r    layoutr   r5   s                G/home/james-whalen/.local/lib/python3.13/site-packages/pyvis/network.py__init__Network.__init__   s   R 


	
$ v	&<#&& >>p@pp>#	GGOOH5E&.>t?P?P.QRG#D(8 4 5 +      c           
          [        [        R                  " U R                  U R                  U R
                  U R                  U R                  S.SS95      $ )z,
override print to show readable graph data
)NodesEdgesHeightWidthHeading   )indent)strjsondumpsr'   r   r   r   r   r7   s    r:   __str__Network.__str__j   sJ     JJ!]]!ZZ"kk!ZZ#|| 	
 	
r=   c                 t    SR                  U R                  U R                  5       U R                  5       5      $ )Nz{} |N|={} |E|={:,})format	__class__	num_nodes	num_edgesrI   s    r:   __repr__Network.__repr__{   s.    #**NNDNN,dnn.>
 	
r=   c                    [        U[        5      (       d  [        U[        5      (       d   eU(       a  UnOUnXR                  ;  a  SU;   a  [	        X4X`R
                  S.UD6nO[	        X4XdU R
                  S.UD6nU R                  R                  UR                  5        U R                  R                  U5        UR                  U R                  U'   gg)a8  
This method adds a node to the network, given a mandatory node ID.
Node labels default to node ids if no label is specified during the
call.

>>> nt = Network("500px", "500px")
>>> nt.add_node(0, label="Node 0")
>>> nt.add_node(1, label="Node 1", color = "blue")

:param n_id: The id of the node. The id is mandatory for nodes and
             they have to be unique. This should obviously be set per
             node, not globally.

:param label: The label is the piece of text shown in or under the
              node, depending on the shape.

:param borderWidth:     The width of the border of the node.

:param borderWidthSelected:     The width of the border of the node when
                            it is selected. When undefined, the
                            borderWidth * 2 is used.

:param brokenImage:     When the shape is set to image or circularImage,
                    this option can be an URL to a backup image in
                    case the URL supplied in the image option cannot
                    be resolved.

:param group: When not undefined, the node will belong to the defined
              group. Styling information of that group will apply to
              this node. Node specific styling overrides group styling.

:param hidden: When true, the node will not be shown. It will still be
               part of the physics simulation though!

:param image: When the shape is set to image or circularImage, this
              option should be the URL to an image. If the image
              cannot be found, the brokenImage option can be used.

:param labelHighlightBold: Determines whether or not the label becomes
                           bold when the node is selected.

:param level: When using the hierarchical layout, the level determines
              where the node is going to be positioned.

:param mass: The barnesHut physics model (which is enabled by default)
             is based on an inverted gravity model. By increasing
             the mass of a node, you increase it's repulsion. Values
             lower than 1 are not recommended.

:param physics: When false, the node is not part of the physics
                simulation. It will not move except for from
                manual dragging.

:param shape: The shape defines what the node looks like. There are
              two types of nodes. One type has the label inside of
              it and the other type has the label underneath it. The
              types with the label inside of it are: ellipse, circle,
              database, box, text. The ones with the label outside of
              it are: image, circularImage, diamond, dot, star,
              triangle, triangleDown, square and icon.

:param size: The size is used to determine the size of node shapes that
             do not have the label inside of them. These shapes are:
             image, circularImage, diamond, dot, star, triangle,
             triangleDown, square and icon.

:param title: Title to be displayed when the user hovers over the node.
              The title can be an HTML element or a string containing
              plain text or HTML.

:param value: When a value is set, the nodes will be scaled using the
              options in the scaling object defined above.

:param x: This gives a node an initial x position. When using the
          hierarchical layout, either the x or y position is set by the
          layout engine depending on the type of view. The other value
          remains untouched. When using stabilization, the stabilized
          position may be different from the initial one. To lock the
          node to that position use the physics or fixed options.

:param y: This gives a node an initial y position. When using the
          hierarchical layout,either the x or y position is set by
          the layout engine depending on the type of view. The
          other value remains untouched. When using stabilization,
          the stabilized position may be different from the initial
          one. To lock the node to that position use the physics or
          fixed options.

:type n_id: str or int
:type label: str or int
:type borderWidth: num (optional)
:type borderWidthSelected: num (optional)
:type brokenImage: str (optional)
:type group: str (optional)
:type hidden: bool (optional)
:type image: str (optional)
:type labelHighlightBold: bool (optional)
:type level: num (optional)
:type mass: num (optional)
:type physics: bool (optional)
:type shape: str (optional)
:type size: num (optional)
:type title: str or html element (optional)
:type value: num (optional)
:type x: num (optional)
:type y: num (optional)
group)labelr    )rU   colorr    N)

isinstancerF   intr'   r	   r    r   appendr%   r(   )r7   n_idrU   r   rV   r%   
node_labelns           r:   add_nodeNetwork.add_node   s    X $$$
4(=(===JJ}}$'!^J??^V]^kJPTP_P_kcjkJJaii(MM  &"#))DMM$ %r=   c                 4   / SQnU H  nXC;   a  M
   SU-   S-   5       e   [        [        5      n[        [        U5      5       Ht  nUR	                  5        H]  u  pG[        U5      [        U5      :X  d&   SU< S[        U5      < S[        U5      < S35       eXQU      R                  XGU   05        M_     Mv     U H$  n [        U5      nU R                  " U40 XX   D6  M&     g!   [        U[        5      (       d   eU R                  " U40 XX   D6   MZ  = f)	aR  
This method adds multiple nodes to the network from a list.
Default behavior uses values of 'nodes' for node ID and node label
properties. You can also specify other lists of properties to go
along each node.

Example:

>>> g = net.Network()
>>> g.add_nodes([1, 2, 3], size=[2, 4, 6], title=["n1", "n2", "n3"])
>>> g.nodes
>>> [{'id': 1, 'label': 1, 'shape': 'dot', 'size': 2, 'title': 'n1'},

Output:

>>> {'id': 2, 'label': 2, 'shape': 'dot', 'size': 4, 'title': 'n2'},
>>> {'id': 3, 'label': 3, 'shape': 'dot', 'size': 6, 'title': 'n3'}]


:param nodes: A list of nodes.

:type nodes: list
)sizevaluetitlexyrU   rV   r   zinvalid arg ''zkeyword arg z	 [length z] does not match[length z
] of nodesN)
r   dictrangelenitemsupdaterX   r]   rW   rF   )	r7   r   kwargs
valid_argskndivnodes	            r:   	add_nodesNetwork.add_nodes   s   01
A?=Oa$7#$==?  s5z"AA#e*,
 #a&#e*, 8##Q!I. ' # D04yd/bh/	 
0!$,,,,d/bh/s    C&&.Dc                 ,    [        U R                  5      $ )z3
Return number of nodes

:returns: :py:class:`int`
)rh   r'   rI   s    r:   rO   Network.num_nodes-  s     4==!!r=   c                 ,    [        U R                  5      $ )z3
Return number of edges

:returns: :py:class:`int`
)rh   r   rI   s    r:   rP   Network.num_edges5  s     4::r=   c                    SnXR                  5       ;   d   S[        U5      -   S-   5       eX R                  5       ;   d   S[        U5      -   S-   5       eU R                  (       d7  U R                   H'  nUS   nUS   nX:X  a  X&:X  d  X:X  d  M  X':X  d  M%  SnM)     U(       d=  [	        XU R                  40 UD6nU R                  R                  UR                  5        gg)a  

Adding edges is done based off of the IDs of the nodes. Order does
not matter unless dealing with a directed graph.

>>> nt.add_edge(0, 1) # adds an edge from node ID 0 to node ID
>>> nt.add_edge(0, 1, value = 4) # adds an edge with a width of 4


:param arrowStrikethrough: When false, the edge stops at the arrow.
                           This can be useful if you have thick lines
                           and you want the arrow to end in a point.
                           Middle arrows are not affected by this.

:param from: Edges are between two nodes, one to and one from. This
             is where you define the from node. You have to supply
             the corresponding node ID. This naturally only applies
             to individual edges.

:param hidden: When true, the edge is not drawn. It is part still part
               of the physics simulation however!

:param physics: When true, the edge is part of the physics simulation.
                When false, it will not act as a spring.

:param title: The title is shown in a pop-up when the mouse moves over
              the edge.

:param to: Edges are between two nodes, one to and one from. This is
           where you define the to node. You have to supply the
           corresponding node ID. This naturally only applies to
           individual edges.

:param value: When a value is set, the edges' width will be scaled
              using the options in the scaling object defined above.

:param width: The width of the edge. If value is set, this is not used.


:type arrowStrikethrough: bool
:type from: str or num
:type hidden: bool
:type physics: bool
:type title: str
:type to: str or num
:type value: num
:type width: num
Fznon existent node 're   fromtoTN)	get_nodesrF   r!   r   r   rY   r%   )r7   sourcerz   r%   edge_existsefrmdests           r:   add_edgeNetwork.add_edge=  s    b  )) 	6!CK/#5	6) ^^%% 	2!CG+c1	2% }}ZZiwBI2: #'K   V:':AJJaii( r=   c                     U HF  n[        U5      S:X  a  U R                  US   US   US   S9  M.  U R                  US   US   5        MH     g)a~  
This method serves to add multiple edges between existing nodes
in the network instance. Adding of the edges is done based off
of the IDs of the nodes. Order does not matter unless dealing with a
directed graph.

:param edges: A list of tuples, each tuple consists of source of edge,
              edge destination and and optional width.

:type arrowStrikethrough: list of tuples
   r   r      )r   N)rh   r   )r7   r   edges      r:   	add_edgesNetwork.add_edges  sM     D4yA~d1gtAwd1g>d1gtAw/ r=   c                    [        U R                  [        5      (       aX  U R                  U R                  U R
                  U R                  U R                  [        R                  " U R                  5      4$ U R                  U R                  U R
                  U R                  U R                  U R                  R                  5       4$ )a  
Extract relevant information about this network in order to inject into
a Jinja2 template.

Returns:
        nodes (list), edges (list), height (
            string), width (string), options (object)

Usage:

>>> nodes, edges, heading, height, width, options = net.get_network_data()
)rW   r%   rf   r   r   r   r   r   rG   rH   to_jsonrI   s    r:   get_network_dataNetwork.get_network_data  s     dllD))JJ

DLL$++JJ

4<< 8: : JJ

DLL$++JJ 4 4 68 8r=   c                 <    [        U5        U R                  U5        g)z
Save the graph as html in the current directory with name.

:param name: the name of the html file to save as
:type name: str
N)r   
write_html)r7   names     r:   
save_graphNetwork.save_graph  s     	4r=   Tc                 .   [        U5        SnU R                   H)  nUR                  SS5      nU(       d  M  SU;   d  M&   Sn  O   U(       d&  U R                  R	                  U R
                  5      nOU R                  nU R                  5       u  ppp[        U R                  [        5      (       a9  SU R                  ;   a&  SU R                  S   ;   a  U R                  S   S   nO#SnO U R                  R                  R                  nUR                  UUUU	U
UUU R                  U R                  U R                   U R"                  U R$                  UU R&                  U R(                  U R*                  UU R,                  S9U l        U R.                  $ )	z
This method gets the data structures supporting the nodes, edges,
and options and updates the template to write the HTML holding
the visualization.
:type name_html: str
Frb   NhrefTphysicsenabled)r   r   r   r   r   r%   physics_enabledr#   r$   r&   r"   r*   tooltip_linkr+   r,   r-   r8   r5   )r   r   getr3   get_templater.   r)   r   rW   r%   rf   r   r   renderr#   r$   r&   r"   r*   r+   r,   r-   r5   r   )r7   r   r   r8   use_link_templater\   rb   r)   r   r   r   r   r   r%   r   s                  r:   generate_htmlNetwork.generate_html  si    	4!AEE'4(EuU?
 )-%   ''44TYY?H}}H8<8M8M8O5gu dllD))DLL(Y$,,y:Q-Q"&,,y"9)"D"&"ll22::OOO6*/*/*/,3,34C,0LL-1]]+/;;,0LL)-1B;?;V;V040@0@040@0@-5262D2D# $ &	& yyr=   c                    Un[        U5        U R                  US9U l        U R                  S:X  Ga  [        R
                  R                  S5      (       d  [        R                  " S5        [        R
                  R                  S5      (       d;  [        R                  " [        R
                  R                  [        5       S3S5        [        R
                  R                  [        R                  " 5       S-   5      (       d;  [        R                  " [        R
                  R                  [        5       S3S5        [        R
                  R                  [        R                  " 5       S	-   5      (       d;  [        R                  " [        R
                  R                  [        5       S
3S5        [        US5       nUR                  U R                  5        SSS5        ORU R                  S:X  d  U R                  S:X  a1  [        US5       nUR                  U R                  5        SSS5        O U(       a  [        R                  " U5        gg! , (       d  f       N-= f! , (       d  f       N>= f)a  
This method gets the data structures supporting the nodes, edges,
and options and updates the template to write the HTML holding
the visualization.

To work with the old local methods local is being depricated, but not removed.
:type name_html: str
@param name: name of the file to save the graph as.
@param local: Depricated parameter. Used to be used to determine how the graph needs deploy. Has been removed in favor of using the class cdn_resources instead.
@param notebook: If true, this object will return the iframe document for use in juptyer notebook.
@param open_browser: If true, will open a web browser with the generated graph.
)r8   r   libzlib/bindingsz/templates/lib/bindingsz/lib/tom-selectz/templates/lib/tom-selectzlib/tom-selectz/lib/vis-9.1.2z/templates/lib/vis-9.1.2zlib/vis-9.1.2zw+Nr   r   )r   r   r   r5   r/   r.   existsmakedirsshutilcopytreer0   r1   getcwdopenwrite
webbrowser)r7   r   r   r8   open_browsergetcwd_nameouts          r:   r   Network.write_html  s    ;&&&9	(77>>%((E"77>>.11277??8#<"==T UWef77>>"))+.?"?@@277??8#<"==V WYij77>>"))+.>">??277??8#<"==U VXghk4(C		$))$ )(9,0B0Bh0Nk4(C		$))$ )( KOOK(  )( )(s   II)
I&)
I7c                     [        U5        U(       a  U R                  USSS9  OU R                  USS9  U(       a  [        XR                  U R                  S9$ g)z
Writes a static HTML file and saves it locally before opening.

:param: name: the name of the html file to save as
:type name: str
FT)r   r8   )r   )r   r   N)r4   r   r   r   r   )r7   r   r   r8   s       r:   showNetwork.show  sM     	dOODudOCOODtO4$jjEE r=   c                     U(       a  U(       a  U R                  U5        U R                  R                  U R                  5      U l        g)a6  
Loads the template data into the template attribute of the network.
This should be done in a jupyter notebook environment before showing
the network.

Example:
        >>> net.prep_notebook()
        >>> net.show("nb.html")


:param path: the relative path pointing to a template html file
:type path: string
N)set_templater3   r   r.   r)   )r7   custom_templatecustom_template_paths      r:   r6   Network.prep_notebook(  s7     323 ((55dii@r=   path_to_templatec                 z    UR                  S5      nU R                  SR                  USS 5      S-   US   5        g)a\  
Path to full template assumes that it exists inside of a template directory.
Use `set_template_dir` to set the relative template path to the template directory along with the directory location itself
to change both values otherwise this function will infer the results.
:path_to_template path: full os path string value of the template directory
/N)splitset_template_dirjoin)r7   r   	str_partss      r:   r   Network.set_template=  s<     %**3/	chhy"~6<imLr=   c                 ^    X l         Xl        [        [        U R                  5      S9U l        g)z
Path to template directory along with the location of the template file.
:template_directory path: template directory
:template_file path: name of the template file that is going to be used to generate the html doc.

r   N)r.   r2   r   r   r3   )r7   template_directorytemplate_files      r:   r   Network.set_template_dirG  s(     "	.&.>t?P?P.QRr=   c                     SU l         [        US5      n[        UR                  5       5      nSR	                  UR                  5       5      U l        U R                  R                  SS5      U l        g)a`  
This method takes the contents of .DOT file and converts it
to a PyVis visualization.

Assuming the contents of test.dot contains:
digraph sample3 {
A -> {B ; C ; D}
C -> {B ; A}
}

Usage:

>>> nt.Network("500px", "500px")
>>> nt.from_DOT("test.dot")
>>> nt.show("dot.html")

:param dot: The path of the dotfile being converted.
:type dot: .dot file

Tr "z\"N)r#   r   rF   readr   
splitlinesr$   replace)r7   r   filess       r:   from_DOTNetwork.from_DOTR  sT    * C~		0--c59r=   c                    0 nU R                    H  n[        5       XS   '   M     U R                  (       a2  U R                   H   nUS   nUS   nX   R	                  U5        M"     U$ U R                   HG  nUS   nUS   nXQU   ;  d  M  XAU   ;  d  M!  X   R	                  U5        X   R	                  U5        MI     U$ )z
This method returns the user an adjacency list representation
of the network.

:returns: dictionary mapping of Node ID to list of Node IDs it
is connected to.
idry   rz   )r   setr!   r   add)r7   a_listro   r~   r|   r   s         r:   get_adj_listNetwork.get_adj_listm  s     A!eFT7O ==ZZ6w""4(    ZZ6wf~-&t2LN&&t,L$$V,   r=   c                     [        U[        5      (       d(  [        U[        5      (       d   S[        U5      -  5       eXR                  ;   d
   SU-  5       eU R                  5       U   $ )z
Given a node id, return the set of neighbors of this particular node.

:param node: The node to get the neighbors from
:type node: str or int

:returns: set
z.error: expected int or str for node but got %szerror: %s node not in network)rW   rF   rX   typer'   r   )r7   rq   s     r:   	neighborsNetwork.neighbors  sg     4%%D#)>)> 	QCd4jP	Q>%N(G$(NN%  "4((r=   c                     U $ N rc   s    r:   <lambda>Network.<lambda>  s    Ar=   c                     U $ r   r   r   s    r:   r   r     s    ^_r=   
   r   c                    [        U[        R                  5      (       d   eUR                  SS9nUR	                  SS9n	[        U5      S:  GaP  U GHI  n
SXS      R                  5       ;  a
  XIU
S      S'   [        U" XS      S   5      5      XS      S'   SXS      R                  5       ;  a
  XIU
S      S'   [        U" XS      S   5      5      XS      S'   U R                  " U
S   40 XS      D6  U R                  " U
S   40 XS      D6  SU
S   ;  d	  SU
S   ;  aX  U(       a  SnOSnS	U
S   R                  5       ;  a  XZS   S	'   U" U
S   S	   5      U
S   U'   U
S   R                  S	5      U
S   U'   U R                  " U
S   U
S   40 U
S   D6  GML     [        R                  " U5       H5  nSX   R                  5       ;  a  XIU   S'   U R                  " U40 X   D6  M7     g
)a  
This method takes an exisitng Networkx graph and translates
it to a PyVis graph format that can be accepted by the VisJs
API in the Jinja2 template. This operation is done in place.

:param nx_graph: The Networkx graph object that is to be translated.
:type nx_graph: networkx.Graph instance
:param node_size_transf: function to transform the node size for plotting
:type node_size_transf: func
:param edge_weight_transf: function to transform the edge weight for plotting
:type edge_weight_transf: func
:param default_node_size: default node size if not specified
:param default_edge_weight: default edge weight if not specified
>>> nx_graph = nx.cycle_graph(10)
>>> nx_graph.nodes[1]['title'] = 'Number 1'
>>> nx_graph.nodes[1]['group'] = 1
>>> nx_graph.nodes[3]['title'] = 'I belong to a different group!'
>>> nx_graph.nodes[3]['group'] = 10
>>> nx_graph.add_node(20, size=20, title='couple', group=2)
>>> nx_graph.add_node(21, size=15, title='couple', group=2)
>>> nx_graph.add_edge(20, 21, weight=5)
>>> nx_graph.add_node(25, size=25, label='lonely', title='lonely node', group=3)
>>> nt = Network("500px", "500px")
# populates the nodes and edges data structures
>>> nt.from_nx(nx_graph)
>>> nt.show("nx.html")
T)datar   r`   r   ra   r   r   weightN)rW   nxGraphr   r   rh   keysrX   r]   popr   isolates)r7   nx_graphnode_size_transfedge_weight_transfdefault_node_sizedefault_edge_weightshow_edge_weightsedge_scalingr   r   r~   
width_typerq   s                r:   from_nxNetwork.from_nx  s   : (BHH--.-nnDn)nnDn)u:>t!1!1!33(9!A$K'$'(8tV9L(M$NdF#t!1!1!33(9!A$K'$'(8tV9L(M$NdF#ad2eaDk2ad2eaDk2 !A$&'1*=#%,
%,
qtyy{2)<!X'9!A$x.'IAaD$'(txx'9AaD$adAaD1AaD1+ . KK)DU[--//&7dF#MM$.%+. *r=   c                     U R                   $ )zB
This method returns an iterable list of node ids

:returns: list
)r'   rI   s    r:   r{   Network.get_nodes  s     }}r=   c                      U R                   U   $ )zu
Lookup node by ID and return it.

:param n_id: The ID given to the node.

:returns: dict containing node properties
)r(   )r7   rZ   s     r:   get_nodeNetwork.get_node  s     }}T""r=   c                     U R                   $ )zF
This method returns an iterable list of edge objects

:returns: list
)r   rI   s    r:   	get_edgesNetwork.get_edges  s     zzr=   c                 ^    U R                   R                  R                  [        5       5        g)a(  
BarnesHut is a quadtree based gravity model. It is the fastest. default
and recommended solver for non-hierarchical layouts.

:param gravity: The more negative the gravity value is, the stronger the
                repulsion is.
:param central_gravity: The gravity attractor to pull the entire network
                        to the center. 
:param spring_length: The rest length of the edges
:param spring_strength: The strong the edges springs are
:param damping: A value ranging from 0 to 1 of how much of the velocity
                from the previous physics simulation iteration carries
                over to the next iteration.
:param overlap: When larger than 0, the size of the node is taken into
                account. The distance will be calculated from the radius
                of the encompassing circle of the node for both the
                gravity model. Value 1 is maximum overlap avoidance.

:type gravity: int
:type central_gravity: float
:type spring_length: int
:type spring_strength: float
:type damping: float
:type overlap: float
N)r%   r   use_barnes_hutlocalsr7   gravitycentral_gravityspring_lengthspring_strengthdampingoverlaps          r:   
barnes_hutNetwork.barnes_hut  s    D 	++FH5r=   c                 ^    U R                   R                  R                  [        5       5        g)a  
Set the physics attribute of the entire network to repulsion.
When called, it sets the solver attribute of physics to repulsion.

:param node_distance: This is the range of influence for the repulsion.
:param central_gravity: The gravity attractor to pull the entire network
                        to the center.
:param spring_length: The rest length of the edges
:param spring_strength: The strong the edges springs are
:param damping: A value ranging from 0 to 1 of how much of the velocity
                from the previous physics simulation iteration carries
                over to the next iteration.

:type node_distance: int
:type central_gravity float
:type spring_length: int
:type spring_strength: float
:type damping: float
N)r%   r   use_repulsionr   r7   node_distancer   r   r   r  s         r:   	repulsionNetwork.repulsion  s    6 	**684r=   c                 ^    U R                   R                  R                  [        5       5        g)a  
This model is based on the repulsion solver but the levels are
taken into account and the forces are normalized.

:param node_distance: This is the range of influence for the repulsion.
:param central_gravity: The gravity attractor to pull the entire network
                        to the center.
:param spring_length: The rest length of the edges
:param spring_strength: The strong the edges springs are
:param damping: A value ranging from 0 to 1 of how much of the velocity
                from the previous physics simulation iteration carries
                over to the next iteration.

:type node_distance: int
:type central_gravity float
:type spring_length: int
:type spring_strength: float
:type damping: float
N)r%   r   use_hrepulsionr   r  s         r:   
hrepulsionNetwork.hrepulsion-  s    6 	++FH5r=   c                 ^    U R                   R                  R                  [        5       5        g)a  
The forceAtlas2Based solver makes use of some of the equations provided
by them and makes use of the barnesHut implementation in vis. The main
differences are the central gravity model, which is here distance
independent, and the repulsion being linear instead of quadratic. Finally,
all node masses have a multiplier based on the amount of connected edges
plus one.

:param gravity: The more negative the gravity value is, the stronger the
                repulsion is.
:param central_gravity: The gravity attractor to pull the entire network
                        to the center. 
:param spring_length: The rest length of the edges
:param spring_strength: The strong the edges springs are
:param damping: A value ranging from 0 to 1 of how much of the velocity
                from the previous physics simulation iteration carries
                over to the next iteration.
:param overlap: When larger than 0, the size of the node is taken into
                account. The distance will be calculated from the radius
                of the encompassing circle of the node for both the
                gravity model. Value 1 is maximum overlap avoidance.

:type gravity: int
:type central_gravity: float
:type spring_length: int
:type spring_strength: float
:type damping: float
:type overlap: float
N)r%   r   use_force_atlas_2basedr   r   s          r:   force_atlas_2basedNetwork.force_atlas_2basedJ  s    L 	33FH=r=   c                 4    [         R                  " U 4SU0UD6$ )N	max_depth)
jsonpickleencode)r7   r  argss      r:   r   Network.to_jsonr  s      CCdCCr=   c                     SU R                   R                  R                  l        XR                   R                  R                  l        g)a$  
Sets the smooth.type attribute of the edges.

:param smooth_type: Possible options: 'dynamic', 'continuous',
                    'discrete', 'diagonalCross', 'straightCross',
                    'horizontal', 'vertical', 'curvedCW',
                    'curvedCCW', 'cubicBezier'.
                    When using dynamic, the edges will have an
                    invisible support node guiding the shape.
                    This node is part of the physics simulation.
                    Default is set to continous.

:type smooth_type: string
TN)r%   r   smoothr   r   )r7   smooth_types     r:   set_edge_smoothNetwork.set_edge_smoothu  s2     -1!!))4!!&r=   c                 8    XR                   R                  l        g)z
Displays or hides edges while dragging the network. This makes
panning of the network easy.

:param status: True if edges should be hidden on drag

:type status: bool
N)r%   interactionhideEdgesOnDragr7   statuss     r:   toggle_hide_edges_on_drag!Network.toggle_hide_edges_on_drag  s     4:  0r=   c                 8    XR                   R                  l        g)z
Displays or hides nodes while dragging the network. This makes
panning of the network easy.

:param status: When set to True, the nodes will hide on drag.
               Default is set to False.

:type status: bool
N)r%   r  hideNodesOnDragr!  s     r:   toggle_hide_nodes_on_drag!Network.toggle_hide_nodes_on_drag  s     4:  0r=   c                 N    U R                   R                  R                  U5        g)z
Edges take on the color of the node they are coming from.

:param status: True if edges should adopt color coming from.
:type status: bool
N)r%   r   inherit_colorsr!  s     r:   inherit_edge_colorsNetwork.inherit_edge_colors  s     	))&1r=   c                 R    SU l         [        SUS9U R                  l        SU l        g)a  
Displays or hides certain widgets to dynamically modify the
network.

Usage:
>>> g.show_buttons(filter_=['nodes', 'edges', 'physics'])

Or to show all options:
>>> g.show_buttons()

:param status: When set to True, the widgets will be shown.
               Default is set to False.
:param filter_: Only include widgets specified by `filter_`.
                Valid options: True (gives all widgets)
                               List of `nodes`, `edges`,
                               `layout`, `interaction`,
                               `manipulation`, `physics`,
                               `selection`, `renderer`.

:type status: bool
:type filter_: bool or list:
T)r   filter_N)r*   r   r%   	configurer&   )r7   r.  s     r:   show_buttonsNetwork.show_buttons  s%    . 	!*4!Ir=   c                 8    XR                   R                  l        g)z
Toggles physics simulation 

:param status: When False, nodes are not part of the physics
               simulation. They will not move except for from
               manual dragging.
               Default is set to True.

:type status: bool
N)r%   r   r   r!  s     r:   toggle_physicsNetwork.toggle_physics  s     (.$r=   c                 8    XR                   R                  l        g)z
Toggles the dragging of the nodes in the network.

:param status: When set to True, the nodes can be dragged around
               in the network. Default is set to True.

:type status: bool
N)r%   r  	dragNodesr!  s     r:   toggle_drag_nodesNetwork.toggle_drag_nodes  s     .4  *r=   c                 N    U R                   R                  R                  U5        g)zf
Toggles the stablization of the network.

:param status: Default is set to True.

:type status: bool
N)r%   r   toggle_stabilizationr!  s     r:   r:  Network.toggle_stabilization  s     	11&9r=   c                 D    U R                   R                  U5      U l         g)a  
Overrides the default options object passed to the VisJS framework.
Delegates to the :meth:`options.Options.set` routine.

:param options: The string representation of the Javascript-like object
                to be used to override default options.

:type options: str
N)r%   r   )r7   r%   s     r:   set_optionsNetwork.set_options  s     ||''0r=   )r"   r5   r*   r!   r$   r   r-   r    r   r   r   r+   r'   r(   r   r%   r.   r,   r   r)   r3   r2   r#   r&   r   )600pxz100%FFFFFz#ffffffFNr   r   )Nr   z#97c2fc)z
index.htmlTF)TFF)TT)FN)r   )ig333333?   gMbP?
ףp=
?r   )d   g?   g?rA  )x   g        rB  {Gz?rA  )irE  rB  g{Gz?g?r   )r   r   )-__name__
__module____qualname____firstlineno____doc__r;   rJ   rQ   r]   rr   rO   rP   r   r   r   r   r   r   r   r6   rF   r   r   r   r   r   r   r{   r   r   r  r	  r  r  r   r  r#  r'  r+  r0  r3  r7  r:  r=  __static_attributes__r   r=   r:   r   r      sh     (-"""!&K!Z
"

x,t10f"H)T0&8(:x")JF  CGA*MS M	S:62) 3>T_#%1PTch</|# !"6L  5>  6>   &>PD5$	:
:26.	4:
1r=   r   )rG   r/   r   tempfiler   collectionsr   r  networkxr   IPython.displayr   jinja2r   r   r   r   rq   r	   r%   r
   r   utilsr   objectr   r   r=   r:   <module>rS     s=     	    #   " 0   ' [1f [1r=   