o
    ˷e                    @   s   d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
 G dd dZG dd deZG dd	 d	eZG d
d deZdd Zdd Zdd ZdS )    N)GraphMLWriter)edges_equalnodes_equalc                   @   s   e Zd Zedd ZdS )BaseGraphMLc                 C   s4  d| _ t | _| jd | jjdddd | jdd | jg d t| j 	d| _
d	| _tjd
d| _ddi| jjd< | jjddd | jjddd | jjddd | jd | jjddd | jjddddd | jjddddd | jjddddd | jjdddd | jjdddd | jjdddd | jjddd d!d t| j	d| _d"| _tjd
d| _d#d$d$d%d%d&d'| jjd< | jd | jd | jjdddd t| j	d| _d(| _t | _| jjd)d*d+d, | jjd-d.d+d, | jjd)d-d/d0 t| j	d}|| _d1| _t | _| jjdd2d3 | jjddd3 | jjddd2d3 | jjdddd3 t| j	d}|| _d4| _t | _| jd | jjdddd | jd5d6g t| j	d}|| _d7| _t | _| jd | jjdddd | jjdddd | jjdddd t| j	d}|| _d8| _ t | _!| j!d | j!jdddd | j!jdddd | j!jdddd t| j 	d}|| _"d9| _#t | _$| j$d | j$dd | j$jdddd | j$jdddd t| j#	d}|| _%d S ):Na  <?xml version="1.0" encoding="UTF-8"?>
<!-- This file was written by the JAVA GraphML Library.-->
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <graph id="G" edgedefault="directed">
    <node id="n0"/>
    <node id="n1"/>
    <node id="n2"/>
    <node id="n3"/>
    <node id="n4"/>
    <node id="n5"/>
    <node id="n6"/>
    <node id="n7"/>
    <node id="n8"/>
    <node id="n9"/>
    <node id="n10"/>
    <edge id="foo" source="n0" target="n2"/>
    <edge source="n1" target="n2"/>
    <edge source="n2" target="n3"/>
    <edge source="n3" target="n5"/>
    <edge source="n3" target="n4"/>
    <edge source="n4" target="n6"/>
    <edge source="n6" target="n5"/>
    <edge source="n5" target="n7"/>
    <edge source="n6" target="n8"/>
    <edge source="n8" target="n7"/>
    <edge source="n8" target="n9"/>
  </graph>
</graphml>n10n0n2fooid)
n1r   r   n3)r   n5)r   n4)r   n6)r   r   )r   n7)r   n8)r   r   )r   n9UTF-8a  <?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
        http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <key id="d0" for="node" attr.name="color" attr.type="string">
    <default>yellow</default>
  </key>
  <key id="d1" for="edge" attr.name="weight" attr.type="double"/>
  <graph id="G" edgedefault="directed">
    <node id="n0">
      <data key="d0">green</data>
    </node>
    <node id="n1"/>
    <node id="n2">
      <data key="d0">blue</data>
    </node>
    <node id="n3">
      <data key="d0">red</data>
    </node>
    <node id="n4"/>
    <node id="n5">
      <data key="d0">turquoise</data>
    </node>
    <edge id="e0" source="n0" target="n2">
      <data key="d1">1.0</data>
    </edge>
    <edge id="e1" source="n0" target="n1">
      <data key="d1">1.0</data>
    </edge>
    <edge id="e2" source="n1" target="n3">
      <data key="d1">2.0</data>
    </edge>
    <edge id="e3" source="n3" target="n2"/>
    <edge id="e4" source="n2" target="n4"/>
    <edge id="e5" source="n3" target="n5"/>
    <edge id="e6" source="n5" target="n4">
      <data key="d1">1.1</data>
    </edge>
  </graph>
</graphml>
Gcoloryellownode_defaultgreen)r   bluer   redr   r   	turquoisee0g      ?)r   weightr   e1e2g       @e3e4e5e6皙?a  <?xml version="1.0" encoding="UTF-8"?>
        <graphml xmlns="http://graphml.graphdrawing.org/xmlns"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
                http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
          <key id="d0" for="node" attr.name="boolean_attribute" attr.type="boolean"><default>false</default></key>
          <key id="d1" for="node" attr.name="int_attribute" attr.type="int"><default>0</default></key>
          <key id="d2" for="node" attr.name="long_attribute" attr.type="long"><default>0</default></key>
          <key id="d3" for="node" attr.name="float_attribute" attr.type="float"><default>0.0</default></key>
          <key id="d4" for="node" attr.name="double_attribute" attr.type="double"><default>0.0</default></key>
          <key id="d5" for="node" attr.name="string_attribute" attr.type="string"><default>Foo</default></key>
          <graph id="G" edgedefault="directed">
            <node id="n0"/>
            <node id="n1"/>
            <edge id="e0" source="n0" target="n1"/>
          </graph>
        </graphml>
        Fr   g        Foo)boolean_attributeint_attributelong_attributefloat_attributedouble_attributestring_attributeaV  <?xml version='1.0' encoding='utf-8'?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <key id="edge_prop" for="edge" attr.name="edge_prop" attr.type="string"/>
  <key id="prop2" for="node" attr.name="prop2" attr.type="string"/>
  <key id="prop1" for="node" attr.name="prop1" attr.type="string"/>
  <graph edgedefault="directed">
    <node id="0">
      <data key="prop1">val1</data>
      <data key="prop2">val2</data>
    </node>
    <node id="1">
      <data key="prop1">val_one</data>
      <data key="prop2">val2</data>
    </node>
    <edge source="0" target="1">
      <data key="edge_prop">edge_value</data>
    </edge>
  </graph>
</graphml>
0val1val2)prop1prop21val_one
edge_value)	edge_propaC  <?xml version='1.0' encoding='utf-8'?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <key attr.name="weight" attr.type="double" for="node" id="d1" />
  <key attr.name="weight" attr.type="double" for="edge" id="d0" />
  <graph edgedefault="directed">
    <node id="n0">
      <data key="d1">1</data>
    </node>
    <node id="n1">
      <data key="d1">2.0</data>
    </node>
    <edge source="n0" target="n1">
      <data key="d0">1</data>
    </edge>
    <edge source="n1" target="n0">
      <data key="d0">k</data>
    </edge>
    <edge source="n1" target="n1">
      <data key="d0">1.0</data>
    </edge>
  </graph>
</graphml>
   r    a  <?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <graph id="G">
    <node id="n0"/>
    <node id="n1"/>
    <node id="n2"/>
    <node id="n10"/>
    <edge id="foo" source="n0" target="n2"/>
    <edge source="n1" target="n2"/>
    <edge source="n2" target="n3"/>
  </graph>
</graphml>r   r   a  <?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <graph id="G">
    <node id="n0"/>
    <node id="n1"/>
    <node id="n2"/>
    <node id="n10"/>
    <edge id="e0" source="n0" target="n2"/>
    <edge id="e1" source="n1" target="n2"/>
    <edge id="e2" source="n2" target="n1"/>
  </graph>
</graphml>a  <?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <graph id="G">
    <node id="n0"/>
    <node id="n1"/>
    <node id="n2"/>
    <node id="n10"/>
    <edge id="e0" source="n0" target="n2"/>
    <edge id="e1" source="n1" target="n2"/>
    <edge id="e2" source="n2" target="n3"/>
  </graph>
</graphml>a  <?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <graph id="G">
    <node id="n0"/>
    <node id="n1"/>
    <node id="n2"/>
    <node id="n10"/>
    <edge source="n0" target="n2"/>
    <edge id="e1" source="n1" target="n2"/>
    <edge id="e2" source="n2" target="n1"/>
  </graph>
</graphml>)&simple_directed_datanxDiGraphsimple_directed_graphadd_nodeadd_edgeadd_edges_fromioBytesIOencodesimple_directed_fhattribute_dataattribute_graphgraphattribute_fhnode_attribute_default_datanode_attribute_default_graphnode_attribute_default_fhattribute_named_key_ids_dataattribute_named_key_ids_graphattribute_named_key_ids_fhattribute_numeric_type_dataattribute_numeric_type_graphattribute_numeric_type_fhsimple_undirected_dataGraphsimple_undirected_graphsimple_undirected_fhundirected_multigraph_data
MultiGraphundirected_multigraphundirected_multigraph_fh'undirected_multigraph_no_multiedge_data"undirected_multigraph_no_multiedge%undirected_multigraph_no_multiedge_fh'multigraph_only_ids_for_multiedges_data"multigraph_only_ids_for_multiedges%multigraph_only_ids_for_multiedges_fh)clsfh rb   \/var/www/ideatree/venv/lib/python3.10/site-packages/networkx/readwrite/tests/test_graphml.pysetup_class   s   
*







zBaseGraphML.setup_classN)__name__
__module____qualname__classmethodrd   rb   rb   rb   rc   r      s    r   c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%S )&TestReadGraphMLc                 C   s   | j }t| j}t| t| ksJ t| t| ks%J t|jddt|jddks7J | jd t| j	}t| t| ksQJ t| t| ks_J t|jddt|jddksqJ d S NTdatar   )
r=   r;   read_graphmlrD   sortednodesedgesseekparse_graphmlr:   selfr   HPGrb   rb   rc   !test_read_simple_directed_graphml<  s   $(z1TestReadGraphML.test_read_simple_directed_graphmlc                 C      | j }t| j}t| | sJ t| | sJ | jd t	| j
}t| | s6J t| | sAJ d S Nr   )rT   r;   rm   rU   r   ro   r   rp   rq   rr   rR   rs   rb   rb   rc   #test_read_simple_undirected_graphmlI     z3TestReadGraphML.test_read_simple_undirected_graphmlc                 C   rx   ry   )rX   r;   rm   rY   r   ro   r   rp   rq   rr   rV   rs   rb   rb   rc   'test_read_undirected_multigraph_graphmlT  r{   z7TestReadGraphML.test_read_undirected_multigraph_graphmlc                 C   rx   ry   )r[   r;   rm   r\   r   ro   r   rp   rq   rr   rZ   rs   rb   rb   rc   4test_read_undirected_multigraph_no_multiedge_graphml_  r{   zDTestReadGraphML.test_read_undirected_multigraph_no_multiedge_graphmlc                 C   rx   ry   )r^   r;   rm   r_   r   ro   r   rp   rq   rr   r]   rs   rb   rb   rc   ?test_read_undirected_multigraph_only_ids_for_multiedges_graphmlj  r{   zOTestReadGraphML.test_read_undirected_multigraph_only_ids_for_multiedges_graphmlc                 C   s   | j }t| j}t|dt|jddsJ t|jdd}t|jdd}t||D ]
\}}||ks8J q.| j	d t
| j}t|dt|jddksVJ t|jdd}t|jdd}t||D ]
\}}||ksuJ qkd S rj   )rF   r;   rm   rH   r   ro   rn   rp   ziprq   rr   rE   )rt   r   ru   geheabrv   rb   rb   rc   test_read_attribute_graphmlu  s    "z+TestReadGraphML.test_read_attribute_graphmlc                 C   s.   | j }t| j}|jd |jd ksJ d S )Nr   )rJ   r;   rm   rK   rG   )rt   r   ru   rb   rb   rc   #test_node_default_attribute_graphml  s   z3TestReadGraphML.test_node_default_attribute_graphmlc                 C   <   d}t |d}ttjtj| ttjtj| d S )Na  <?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <graph id="G">
    <node id="n0"/>
    <node id="n1"/>
    <node id="n2"/>
    <edge source="n0" target="n1"/>
    <edge source="n1" target="n2" directed='true'/>
  </graph>
</graphml>r   	rA   rB   rC   pytestraisesr;   NetworkXErrorrm   rr   rt   sra   rb   rb   rc    test_directed_edge_in_undirected     z0TestReadGraphML.test_directed_edge_in_undirectedc                 C   r   )Na  <?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <graph id="G" edgedefault='directed'>
    <node id="n0"/>
    <node id="n1"/>
    <node id="n2"/>
    <edge source="n0" target="n1"/>
    <edge source="n1" target="n2" directed='false'/>
  </graph>
</graphml>r   r   r   rb   rb   rc    test_undirected_edge_in_directed  r   z0TestReadGraphML.test_undirected_edge_in_directedc                 C   r   )Na  <?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <key id="d0" for="node" attr.name="color" attr.type="string">
    <default>yellow</default>
  </key>
  <key id="d1" for="edge" attr.name="weight" attr.type="double"/>
  <graph id="G" edgedefault="directed">
    <node id="n0">
      <data key="d0">green</data>
    </node>
    <node id="n1"/>
    <node id="n2">
      <data key="d0">blue</data>
    </node>
    <edge id="e0" source="n0" target="n2">
      <data key="d2">1.0</data>
    </edge>
  </graph>
</graphml>
r   r   r   rb   rb   rc   test_key_raise  s   zTestReadGraphML.test_key_raisec                 C   r   )Na5  <?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <key id="d0" for="node" attr.name="color" attr.type="string">
    <default>yellow</default>
  </key>
  <key id="d1" for="edge" attr.name="weight" attr.type="double"/>
  <graph id="G" edgedefault="directed">
    <node id="n0">
      <data key="d0">green</data>
    </node>
    <node id="n1"/>
    <node id="n2">
      <data key="d0">blue</data>
    </node>
    <hyperedge id="e0" source="n0" target="n2">
       <endpoint node="n0"/>
       <endpoint node="n1"/>
       <endpoint node="n2"/>
    </hyperedge>
  </graph>
</graphml>
r   r   r   rb   rb   rc   test_hyperedge_raise  s   z$TestReadGraphML.test_hyperedge_raisec                 C   sn   d}t |d}t|}ddg}t|jdd|ksJ |d t|}t|jdd|ks5J d S )Na  <?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <graph id="G" edgedefault="directed">
    <node id="n0"/>
    <node id="n1"/>
    <edge id="e0" source="n0" target="n1"/>
    <edge id="e1" source="n0" target="n1"/>
  </graph>
</graphml>
r   )r   r   r   )r   r   r!   Tkeysr   )	rA   rB   rC   r;   rm   rn   rp   rq   rr   rt   r   ra   r   expectedru   rb   rb   rc   test_multigraph_keys  s   


z$TestReadGraphML.test_multigraph_keysc                 C   sT  t  }|d |d |dddtddfddtddfddtdd	d
fdddtddfdddtddfdddtddd
fg t }t || |d t j	|t
d}t|jddd|jdddsjJ |j|jksrJ dd |j D }|d t j	|ttd}||jksJ |d | }t j|ttd}||jksJ dS )zf
        Test that data and keys of edges are preserved on consequent
        write and reads
        r8      )r8   r   	data_key1keydata_id2r
   	data_key3data_id3)r   r   g   	data_key4h   data_id5i   	data_key6data_id7r   	node_typeT)rl   r   c                 S   (   i | ]\}}t |d d | D qS )c                 S   r   )c                 S   s   i | ]	\}}t ||qS rb   str).0ekeyddrb   rb   rc   
<dictcomp>  s    zWTestReadGraphML.test_preserve_multi_edge_data.<locals>.<dictcomp>.<dictcomp>.<dictcomp>r   items)r   nbrkey_dictrb   rb   rc   r     s    zLTestReadGraphML.test_preserve_multi_edge_data.<locals>.<dictcomp>.<dictcomp>r   )r   nodenbr_dictrb   rb   rc   r     s    zATestReadGraphML.test_preserve_multi_edge_data.<locals>.<dictcomp>)r   edge_key_typeN)r;   rW   r>   r@   dictrA   rB   write_graphmlrq   rm   intr   rp   _adjr   r   readrr   )rt   r   ra   ru   GadjHH	string_fhrb   rb   rc   test_preserve_multi_edge_data   s:   


"

z-TestReadGraphML.test_preserve_multi_edge_datac                 C   s  d}t |d}tj|dd}t| dgksJ |jdddd	s&J |jd d
 dks1J |jd d
 dks<J |jd d
 dksGJ |jd d dksRJ |jd d dks]J |jd d dkshJ |jd d dkssJ |	d t|}t| dgksJ |d d d dksJ |jd d
 dksJ |jd d
 dksJ |jd d
 dksJ |jd d dksJ |jd d dksJ |jd d dksJ |jd d dksJ tj
|dd}t| dgksJ |jdddd	sJ |jd d
 dks	J |jd d
 dksJ |jd d
 dks!J t
|}t| dgks2J |d d d dks?J |jd d
 dksKJ |jd d
 dksWJ |jd d
 dkscJ d S )NaI  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:y="http://www.yworks.com/xml/graphml"
         xmlns:yed="http://www.yworks.com/xml/yed/3"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <!--Created by yFiles for Java 2.7-->
  <key for="graphml" id="d0" yfiles.type="resources"/>
  <key attr.name="url" attr.type="string" for="node" id="d1"/>
  <key attr.name="description" attr.type="string" for="node" id="d2"/>
  <key for="node" id="d3" yfiles.type="nodegraphics"/>
  <key attr.name="Description" attr.type="string" for="graph" id="d4">
    <default/>
  </key>
  <key attr.name="url" attr.type="string" for="edge" id="d5"/>
  <key attr.name="description" attr.type="string" for="edge" id="d6"/>
  <key for="edge" id="d7" yfiles.type="edgegraphics"/>
  <graph edgedefault="directed" id="G">
    <node id="n0">
      <data key="d3">
        <y:ShapeNode>
          <y:Geometry height="30.0" width="30.0" x="125.0" y="100.0"/>
          <y:Fill color="#FFCC00" transparent="false"/>
          <y:BorderStyle color="#000000" type="line" width="1.0"/>
          <y:NodeLabel alignment="center" autoSizePolicy="content"
           borderDistance="0.0" fontFamily="Dialog" fontSize="13"
           fontStyle="plain" hasBackgroundColor="false" hasLineColor="false"
           height="19.1328125" modelName="internal" modelPosition="c"
           textColor="#000000" visible="true" width="12.27099609375"
           x="8.864501953125" y="5.43359375">1</y:NodeLabel>
          <y:Shape type="rectangle"/>
        </y:ShapeNode>
      </data>
    </node>
    <node id="n1">
      <data key="d3">
        <y:ShapeNode>
          <y:Geometry height="30.0" width="30.0" x="183.0" y="205.0"/>
          <y:Fill color="#FFCC00" transparent="false"/>
          <y:BorderStyle color="#000000" type="line" width="1.0"/>
          <y:NodeLabel alignment="center" autoSizePolicy="content"
          borderDistance="0.0" fontFamily="Dialog" fontSize="13"
          fontStyle="plain" hasBackgroundColor="false" hasLineColor="false"
          height="19.1328125" modelName="internal" modelPosition="c"
          textColor="#000000" visible="true" width="12.27099609375"
          x="8.864501953125" y="5.43359375">2</y:NodeLabel>
          <y:Shape type="rectangle"/>
        </y:ShapeNode>
      </data>
    </node>
    <node id="n2">
      <data key="d6" xml:space="preserve"><![CDATA[description
line1
line2]]></data>
      <data key="d3">
        <y:GenericNode configuration="com.yworks.flowchart.terminator">
          <y:Geometry height="40.0" width="80.0" x="950.0" y="286.0"/>
          <y:Fill color="#E8EEF7" color2="#B7C9E3" transparent="false"/>
          <y:BorderStyle color="#000000" type="line" width="1.0"/>
          <y:NodeLabel alignment="center" autoSizePolicy="content"
          fontFamily="Dialog" fontSize="12" fontStyle="plain"
          hasBackgroundColor="false" hasLineColor="false" height="17.96875"
          horizontalTextPosition="center" iconTextGap="4" modelName="custom"
          textColor="#000000" verticalTextPosition="bottom" visible="true"
          width="67.984375" x="6.0078125" xml:space="preserve"
          y="11.015625">3<y:LabelModel>
          <y:SmartNodeLabelModel distance="4.0"/></y:LabelModel>
          <y:ModelParameter><y:SmartNodeLabelModelParameter labelRatioX="0.0"
          labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0"
          offsetY="0.0" upX="0.0" upY="-1.0"/></y:ModelParameter></y:NodeLabel>
        </y:GenericNode>
      </data>
    </node>
    <edge id="e0" source="n0" target="n1">
      <data key="d7">
        <y:PolyLineEdge>
          <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
          <y:LineStyle color="#000000" type="line" width="1.0"/>
          <y:Arrows source="none" target="standard"/>
          <y:BendStyle smoothed="false"/>
        </y:PolyLineEdge>
      </data>
    </edge>
  </graph>
  <data key="d0">
    <y:Resources/>
  </data>
</graphml>
r   Tforce_multigraph)r   r   r   r   r   r   labelr4   2r   3
shape_type	rectanglezcom.yworks.flowchart.terminatordescriptionzdescription
line1
line2r   r   )rA   rB   rC   r;   rm   listrp   has_edgero   rq   rr   )rt   rl   ra   r   ru   rb   rb   rc   test_yfiles_extension-  sF   Z


z%TestReadGraphML.test_yfiles_extensionc                 C   s   d}t |d}t|}t|}||fD ]8}|jd d s#J |jd d r,J |jd d r5J |jd d s>J |jd d rGJ |jd	 d sPJ qd S )
NaU  <?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <key id="d0" for="node" attr.name="test" attr.type="boolean">
    <default>false</default>
  </key>
  <graph id="G" edgedefault="directed">
    <node id="n0">
      <data key="d0">true</data>
    </node>
    <node id="n1"/>
    <node id="n2">
      <data key="d0">false</data>
    </node>
    <node id="n3">
      <data key="d0">FaLsE</data>
    </node>
    <node id="n4">
      <data key="d0">True</data>
    </node>
    <node id="n5">
      <data key="d0">0</data>
    </node>
    <node id="n6">
      <data key="d0">1</data>
    </node>
  </graph>
</graphml>
r   r   testr   r   r   r   r   )rA   rB   rC   r;   rm   rr   ro   )rt   r   ra   r   ru   rG   rb   rb   rc   	test_bool  s   

zTestReadGraphML.test_boolc           	      C   s   d}d}d}||fD ]$}t |d}t|}t|}||fD ]}|jd d s-J q"q
t |d}ttj	tj| ttj	tj| d S )Na  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <key id="d0" for="node" attr.name="test" attr.type="boolean">
    <default>false</default>
  </key>
  <graph id="G">
    <node id="n0">
      <data key="d0">true</data>
    </node>
  </graph>
</graphml>
a  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<graphml>
  <key id="d0" for="node" attr.name="test" attr.type="boolean">
    <default>false</default>
  </key>
  <graph id="G">
    <node id="n0">
      <data key="d0">true</data>
    </node>
  </graph>
</graphml>
a%  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<graphml xmlns="https://ghghgh">
  <key id="d0" for="node" attr.name="test" attr.type="boolean">
    <default>false</default>
  </key>
  <graph id="G">
    <node id="n0">
      <data key="d0">true</data>
    </node>
  </graph>
</graphml>
r   r   r   )
rA   rB   rC   r;   rm   rr   ro   r   r   r   )	rt   goodbaduglyr   ra   r   ru   rG   rb   rb   rc   test_graphml_header_line  s   

z(TestReadGraphML.test_graphml_header_linec                 C   sb   d}t |d}t|}dd |jddD }t|dks"J |D ]
}|d d	ks.J q$d S )
NaI  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:java="http://www.yworks.com/xml/yfiles-common/1.0/java" xmlns:sys="http://www.yworks.com/xml/yfiles-common/markup/primitives/2.0" xmlns:x="http://www.yworks.com/xml/yfiles-common/markup/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xmlns:yed="http://www.yworks.com/xml/yed/3" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.1/ygraphml.xsd">
  <!--Created by yEd 3.17-->
  <key attr.name="Description" attr.type="string" for="graph" id="d0"/>
  <key for="port" id="d1" yfiles.type="portgraphics"/>
  <key for="port" id="d2" yfiles.type="portgeometry"/>
  <key for="port" id="d3" yfiles.type="portuserdata"/>
  <key attr.name="CustomProperty" attr.type="string" for="node" id="d4">
    <default/>
  </key>
  <key attr.name="url" attr.type="string" for="node" id="d5"/>
  <key attr.name="description" attr.type="string" for="node" id="d6"/>
  <key for="node" id="d7" yfiles.type="nodegraphics"/>
  <key for="graphml" id="d8" yfiles.type="resources"/>
  <key attr.name="url" attr.type="string" for="edge" id="d9"/>
  <key attr.name="description" attr.type="string" for="edge" id="d10"/>
  <key for="edge" id="d11" yfiles.type="edgegraphics"/>
  <graph edgedefault="directed" id="G">
    <data key="d0"/>
    <node id="n0">
      <data key="d4"><![CDATA[CustomPropertyValue]]></data>
      <data key="d6"/>
      <data key="d7">
        <y:ShapeNode>
          <y:Geometry height="30.0" width="30.0" x="125.0" y="-255.4611111111111"/>
          <y:Fill color="#FFCC00" transparent="false"/>
          <y:BorderStyle color="#000000" raised="false" type="line" width="1.0"/>
          <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="11.634765625" x="9.1826171875" y="6.015625">2<y:LabelModel>
              <y:SmartNodeLabelModel distance="4.0"/>
            </y:LabelModel>
            <y:ModelParameter>
              <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
            </y:ModelParameter>
          </y:NodeLabel>
          <y:Shape type="rectangle"/>
        </y:ShapeNode>
      </data>
    </node>
    <node id="n1" yfiles.foldertype="group">
      <data key="d4"><![CDATA[CustomPropertyValue]]></data>
      <data key="d5"/>
      <data key="d6"/>
      <data key="d7">
        <y:ProxyAutoBoundsNode>
          <y:Realizers active="0">
            <y:GroupNode>
              <y:Geometry height="250.38333333333333" width="140.0" x="-30.0" y="-330.3833333333333"/>
              <y:Fill color="#F5F5F5" transparent="false"/>
              <y:BorderStyle color="#000000" type="dashed" width="1.0"/>
              <y:NodeLabel alignment="right" autoSizePolicy="node_width" backgroundColor="#EBEBEB" borderDistance="0.0" fontFamily="Dialog" fontSize="15" fontStyle="plain" hasLineColor="false" height="21.4609375" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="t" textColor="#000000" verticalTextPosition="bottom" visible="true" width="140.0" x="0.0" y="0.0">Group 3</y:NodeLabel>
              <y:Shape type="roundrectangle"/>
              <y:State closed="false" closedHeight="50.0" closedWidth="50.0" innerGraphDisplayEnabled="false"/>
              <y:Insets bottom="15" bottomF="15.0" left="15" leftF="15.0" right="15" rightF="15.0" top="15" topF="15.0"/>
              <y:BorderInsets bottom="1" bottomF="1.0" left="0" leftF="0.0" right="0" rightF="0.0" top="1" topF="1.0001736111111086"/>
            </y:GroupNode>
            <y:GroupNode>
              <y:Geometry height="50.0" width="50.0" x="0.0" y="60.0"/>
              <y:Fill color="#F5F5F5" transparent="false"/>
              <y:BorderStyle color="#000000" type="dashed" width="1.0"/>
              <y:NodeLabel alignment="right" autoSizePolicy="node_width" backgroundColor="#EBEBEB" borderDistance="0.0" fontFamily="Dialog" fontSize="15" fontStyle="plain" hasLineColor="false" height="21.4609375" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="t" textColor="#000000" verticalTextPosition="bottom" visible="true" width="65.201171875" x="-7.6005859375" y="0.0">Folder 3</y:NodeLabel>
              <y:Shape type="roundrectangle"/>
              <y:State closed="true" closedHeight="50.0" closedWidth="50.0" innerGraphDisplayEnabled="false"/>
              <y:Insets bottom="5" bottomF="5.0" left="5" leftF="5.0" right="5" rightF="5.0" top="5" topF="5.0"/>
              <y:BorderInsets bottom="0" bottomF="0.0" left="0" leftF="0.0" right="0" rightF="0.0" top="0" topF="0.0"/>
            </y:GroupNode>
          </y:Realizers>
        </y:ProxyAutoBoundsNode>
      </data>
      <graph edgedefault="directed" id="n1:">
        <node id="n1::n0" yfiles.foldertype="group">
          <data key="d4"><![CDATA[CustomPropertyValue]]></data>
          <data key="d5"/>
          <data key="d6"/>
          <data key="d7">
            <y:ProxyAutoBoundsNode>
              <y:Realizers active="0">
                <y:GroupNode>
                  <y:Geometry height="83.46111111111111" width="110.0" x="-15.0" y="-292.9222222222222"/>
                  <y:Fill color="#F5F5F5" transparent="false"/>
                  <y:BorderStyle color="#000000" type="dashed" width="1.0"/>
                  <y:NodeLabel alignment="right" autoSizePolicy="node_width" backgroundColor="#EBEBEB" borderDistance="0.0" fontFamily="Dialog" fontSize="15" fontStyle="plain" hasLineColor="false" height="21.4609375" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="t" textColor="#000000" verticalTextPosition="bottom" visible="true" width="110.0" x="0.0" y="0.0">Group 1</y:NodeLabel>
                  <y:Shape type="roundrectangle"/>
                  <y:State closed="false" closedHeight="50.0" closedWidth="50.0" innerGraphDisplayEnabled="false"/>
                  <y:Insets bottom="15" bottomF="15.0" left="15" leftF="15.0" right="15" rightF="15.0" top="15" topF="15.0"/>
                  <y:BorderInsets bottom="1" bottomF="1.0" left="0" leftF="0.0" right="0" rightF="0.0" top="1" topF="1.0001736111111086"/>
                </y:GroupNode>
                <y:GroupNode>
                  <y:Geometry height="50.0" width="50.0" x="0.0" y="60.0"/>
                  <y:Fill color="#F5F5F5" transparent="false"/>
                  <y:BorderStyle color="#000000" type="dashed" width="1.0"/>
                  <y:NodeLabel alignment="right" autoSizePolicy="node_width" backgroundColor="#EBEBEB" borderDistance="0.0" fontFamily="Dialog" fontSize="15" fontStyle="plain" hasLineColor="false" height="21.4609375" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="t" textColor="#000000" verticalTextPosition="bottom" visible="true" width="65.201171875" x="-7.6005859375" y="0.0">Folder 1</y:NodeLabel>
                  <y:Shape type="roundrectangle"/>
                  <y:State closed="true" closedHeight="50.0" closedWidth="50.0" innerGraphDisplayEnabled="false"/>
                  <y:Insets bottom="5" bottomF="5.0" left="5" leftF="5.0" right="5" rightF="5.0" top="5" topF="5.0"/>
                  <y:BorderInsets bottom="0" bottomF="0.0" left="0" leftF="0.0" right="0" rightF="0.0" top="0" topF="0.0"/>
                </y:GroupNode>
              </y:Realizers>
            </y:ProxyAutoBoundsNode>
          </data>
          <graph edgedefault="directed" id="n1::n0:">
            <node id="n1::n0::n0">
              <data key="d4"><![CDATA[CustomPropertyValue]]></data>
              <data key="d6"/>
              <data key="d7">
                <y:ShapeNode>
                  <y:Geometry height="30.0" width="30.0" x="50.0" y="-255.4611111111111"/>
                  <y:Fill color="#FFCC00" transparent="false"/>
                  <y:BorderStyle color="#000000" raised="false" type="line" width="1.0"/>
                  <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="11.634765625" x="9.1826171875" y="6.015625">1<y:LabelModel>
                      <y:SmartNodeLabelModel distance="4.0"/>
                    </y:LabelModel>
                    <y:ModelParameter>
                      <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
                    </y:ModelParameter>
                  </y:NodeLabel>
                  <y:Shape type="rectangle"/>
                </y:ShapeNode>
              </data>
            </node>
            <node id="n1::n0::n1">
              <data key="d4"><![CDATA[CustomPropertyValue]]></data>
              <data key="d6"/>
              <data key="d7">
                <y:ShapeNode>
                  <y:Geometry height="30.0" width="30.0" x="0.0" y="-255.4611111111111"/>
                  <y:Fill color="#FFCC00" transparent="false"/>
                  <y:BorderStyle color="#000000" raised="false" type="line" width="1.0"/>
                  <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="11.634765625" x="9.1826171875" y="6.015625">3<y:LabelModel>
                      <y:SmartNodeLabelModel distance="4.0"/>
                    </y:LabelModel>
                    <y:ModelParameter>
                      <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
                    </y:ModelParameter>
                  </y:NodeLabel>
                  <y:Shape type="rectangle"/>
                </y:ShapeNode>
              </data>
            </node>
          </graph>
        </node>
        <node id="n1::n1" yfiles.foldertype="group">
          <data key="d4"><![CDATA[CustomPropertyValue]]></data>
          <data key="d5"/>
          <data key="d6"/>
          <data key="d7">
            <y:ProxyAutoBoundsNode>
              <y:Realizers active="0">
                <y:GroupNode>
                  <y:Geometry height="83.46111111111111" width="110.0" x="-15.0" y="-179.4611111111111"/>
                  <y:Fill color="#F5F5F5" transparent="false"/>
                  <y:BorderStyle color="#000000" type="dashed" width="1.0"/>
                  <y:NodeLabel alignment="right" autoSizePolicy="node_width" backgroundColor="#EBEBEB" borderDistance="0.0" fontFamily="Dialog" fontSize="15" fontStyle="plain" hasLineColor="false" height="21.4609375" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="t" textColor="#000000" verticalTextPosition="bottom" visible="true" width="110.0" x="0.0" y="0.0">Group 2</y:NodeLabel>
                  <y:Shape type="roundrectangle"/>
                  <y:State closed="false" closedHeight="50.0" closedWidth="50.0" innerGraphDisplayEnabled="false"/>
                  <y:Insets bottom="15" bottomF="15.0" left="15" leftF="15.0" right="15" rightF="15.0" top="15" topF="15.0"/>
                  <y:BorderInsets bottom="1" bottomF="1.0" left="0" leftF="0.0" right="0" rightF="0.0" top="1" topF="1.0001736111111086"/>
                </y:GroupNode>
                <y:GroupNode>
                  <y:Geometry height="50.0" width="50.0" x="0.0" y="60.0"/>
                  <y:Fill color="#F5F5F5" transparent="false"/>
                  <y:BorderStyle color="#000000" type="dashed" width="1.0"/>
                  <y:NodeLabel alignment="right" autoSizePolicy="node_width" backgroundColor="#EBEBEB" borderDistance="0.0" fontFamily="Dialog" fontSize="15" fontStyle="plain" hasLineColor="false" height="21.4609375" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="t" textColor="#000000" verticalTextPosition="bottom" visible="true" width="65.201171875" x="-7.6005859375" y="0.0">Folder 2</y:NodeLabel>
                  <y:Shape type="roundrectangle"/>
                  <y:State closed="true" closedHeight="50.0" closedWidth="50.0" innerGraphDisplayEnabled="false"/>
                  <y:Insets bottom="5" bottomF="5.0" left="5" leftF="5.0" right="5" rightF="5.0" top="5" topF="5.0"/>
                  <y:BorderInsets bottom="0" bottomF="0.0" left="0" leftF="0.0" right="0" rightF="0.0" top="0" topF="0.0"/>
                </y:GroupNode>
              </y:Realizers>
            </y:ProxyAutoBoundsNode>
          </data>
          <graph edgedefault="directed" id="n1::n1:">
            <node id="n1::n1::n0">
              <data key="d4"><![CDATA[CustomPropertyValue]]></data>
              <data key="d6"/>
              <data key="d7">
                <y:ShapeNode>
                  <y:Geometry height="30.0" width="30.0" x="0.0" y="-142.0"/>
                  <y:Fill color="#FFCC00" transparent="false"/>
                  <y:BorderStyle color="#000000" raised="false" type="line" width="1.0"/>
                  <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="11.634765625" x="9.1826171875" y="6.015625">5<y:LabelModel>
                      <y:SmartNodeLabelModel distance="4.0"/>
                    </y:LabelModel>
                    <y:ModelParameter>
                      <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
                    </y:ModelParameter>
                  </y:NodeLabel>
                  <y:Shape type="rectangle"/>
                </y:ShapeNode>
              </data>
            </node>
            <node id="n1::n1::n1">
              <data key="d4"><![CDATA[CustomPropertyValue]]></data>
              <data key="d6"/>
              <data key="d7">
                <y:ShapeNode>
                  <y:Geometry height="30.0" width="30.0" x="50.0" y="-142.0"/>
                  <y:Fill color="#FFCC00" transparent="false"/>
                  <y:BorderStyle color="#000000" raised="false" type="line" width="1.0"/>
                  <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="11.634765625" x="9.1826171875" y="6.015625">6<y:LabelModel>
                      <y:SmartNodeLabelModel distance="4.0"/>
                    </y:LabelModel>
                    <y:ModelParameter>
                      <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
                    </y:ModelParameter>
                  </y:NodeLabel>
                  <y:Shape type="rectangle"/>
                </y:ShapeNode>
              </data>
            </node>
          </graph>
        </node>
      </graph>
    </node>
    <node id="n2">
      <data key="d4"><![CDATA[CustomPropertyValue]]></data>
      <data key="d6"/>
      <data key="d7">
        <y:ShapeNode>
          <y:Geometry height="30.0" width="30.0" x="125.0" y="-142.0"/>
          <y:Fill color="#FFCC00" transparent="false"/>
          <y:BorderStyle color="#000000" raised="false" type="line" width="1.0"/>
          <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" horizontalTextPosition="center" iconTextGap="4" modelName="custom" textColor="#000000" verticalTextPosition="bottom" visible="true" width="11.634765625" x="9.1826171875" y="6.015625">9<y:LabelModel>
              <y:SmartNodeLabelModel distance="4.0"/>
            </y:LabelModel>
            <y:ModelParameter>
              <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
            </y:ModelParameter>
          </y:NodeLabel>
          <y:Shape type="rectangle"/>
        </y:ShapeNode>
      </data>
    </node>
    <edge id="n1::n1::e0" source="n1::n1::n0" target="n1::n1::n1">
      <data key="d10"/>
      <data key="d11">
        <y:PolyLineEdge>
          <y:Path sx="15.0" sy="-0.0" tx="-15.0" ty="-0.0"/>
          <y:LineStyle color="#000000" type="line" width="1.0"/>
          <y:Arrows source="none" target="standard"/>
          <y:BendStyle smoothed="false"/>
        </y:PolyLineEdge>
      </data>
    </edge>
    <edge id="n1::n0::e0" source="n1::n0::n1" target="n1::n0::n0">
      <data key="d10"/>
      <data key="d11">
        <y:PolyLineEdge>
          <y:Path sx="15.0" sy="-0.0" tx="-15.0" ty="-0.0"/>
          <y:LineStyle color="#000000" type="line" width="1.0"/>
          <y:Arrows source="none" target="standard"/>
          <y:BendStyle smoothed="false"/>
        </y:PolyLineEdge>
      </data>
    </edge>
    <edge id="e0" source="n1::n0::n0" target="n0">
      <data key="d10"/>
      <data key="d11">
        <y:PolyLineEdge>
          <y:Path sx="15.0" sy="-0.0" tx="-15.0" ty="-0.0"/>
          <y:LineStyle color="#000000" type="line" width="1.0"/>
          <y:Arrows source="none" target="standard"/>
          <y:BendStyle smoothed="false"/>
        </y:PolyLineEdge>
      </data>
    </edge>
    <edge id="e1" source="n1::n1::n1" target="n2">
      <data key="d10"/>
      <data key="d11">
        <y:PolyLineEdge>
          <y:Path sx="15.0" sy="-0.0" tx="-15.0" ty="-0.0"/>
          <y:LineStyle color="#000000" type="line" width="1.0"/>
          <y:Arrows source="none" target="standard"/>
          <y:BendStyle smoothed="false"/>
        </y:PolyLineEdge>
      </data>
    </edge>
  </graph>
  <data key="d8">
    <y:Resources/>
  </data>
</graphml>
r   c                 S   s   g | ]\}}|qS rb   rb   )r   _xrb   rb   rc   
<listcomp>*      zDTestReadGraphML.test_read_attributes_with_groups.<locals>.<listcomp>Trk   	   CustomProperty )rA   rB   rC   r;   rm   ro   len)rt   rl   ra   r   	node_datarb   rb   rc    test_read_attributes_with_groups  s     
z0TestReadGraphML.test_read_attributes_with_groupsc                 C   st   d}t |d}t|}dddifg}t|jdd|ks"J |d t|}t|jdd|ks8J d S )	Na  <?xml version='1.0' encoding='utf-8'?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <key attr.name="cudfversion" attr.type="long" for="node" id="d6" />
  <graph edgedefault="directed">
    <node id="n1">
      <data key="d6">4284</data>
    </node>
  </graph>
</graphml>r   r   cudfversioni  Trk   r   )	rA   rB   rC   r;   rm   rn   ro   rq   rr   r   rb   rb   rc   test_long_attribute_type/  s   


z(TestReadGraphML.test_long_attribute_typeN)re   rf   rg   rw   rz   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   rb   rb   rb   rc   ri   ;  s,    - +3  &ri   c                   @   s   e Zd ZeejZedd Zdd Z	dd Z
dd Zd	d
 Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+S ),TestWriteGraphMLc                 C   s   t   td}d S )N
lxml.etree)r   rd   r   importorskip)r`   r   rb   rb   rc   rd   J  s   zTestWriteGraphML.setup_classc                 C   sD   zdd l }tjtjksJ W d S  ty!   tjtjksJ Y d S w ry   )
lxml.etreer;   r   write_graphml_lxmlImportErrorwrite_graphml_xml)rt   lxmlrb   rb   rc   test_write_interfaceO  s   z%TestWriteGraphML.test_write_interfacec                 C   s   | j }d|jd< t }| || |d t|}t|	 t|	 ks*J t|
 t|
 ks8J t|j
ddt|j
ddksJJ | jd d S )Ntherehir   Trk   r=   rG   rA   rB   writerrq   r;   rm   rn   ro   rp   rD   rt   r   ra   ru   rb   rb   rc   'test_write_read_simple_directed_graphmlW  s   


$z8TestWriteGraphML.test_write_read_simple_directed_graphmlc                 C   s&   t  }| j}| }|||g d S N)r   r=   copy
add_graphs)rt   gmlwr   ru   rb   rb   rc   test_GraphMLWriter_add_graphsc  s   z.TestWriteGraphML.test_GraphMLWriter_add_graphsc                 C   s   | j }d|jd< d|jd< t }| j||dd |d t|}t|	 t|	 ks1J t|
 t|
 ks?J t|j
dd	t|j
dd	ksQJ | jd d S )
Nr   r   r4   r   F)prettyprintr   Trk   r   r   rb   rb   rc   %test_write_read_simple_no_prettyprinti  s   



$z6TestWriteGraphML.test_write_read_simple_no_prettyprintc                 C   s  ddl m} | j}t }| j||dd |d t|}|d t	|
 |
 s/J t| | s:J t|jdd|jddsIJ | jd ||}t| }t|dksaJ dd |d d	 D }t|d	kstJ d
|d v s|J d|d v sJ d|d v sJ d|d v sJ d|d v sJ d|d v sJ t }t|| |d t|}t }	tj||	dd |	d t|	}
tdd t|j
|
j
D sJ tdd t|j|
jD sJ d S )Nr   parseT)named_key_idsrk      c                 S      g | ]}|  qS rb   r   r   childrb   rb   rc   r     r   zTTestWriteGraphML.test_write_read_attribute_named_key_ids_graphml.<locals>.<listcomp>   )r   r7   )	attr.namer7   )r   r3   r8   )r   r3   )r   r2   r   )r   r2   c                 s       | ]	\}}||kV  qd S r   rb   )r   r   r   rb   rb   rc   	<genexpr>      zSTestWriteGraphML.test_write_read_attribute_named_key_ids_graphml.<locals>.<genexpr>c                 s   r   r   rb   )r   r!   r"   rb   rb   rc   r     r   )xml.etree.ElementTreer   rM   rA   rB   r   rq   r;   rm   r   ro   r   rp   rN   r   getrootr   r   allr   )rt   r   r   ra   ru   xmlchildrenr   default_behavior_fhnamed_key_ids_behavior_fhJrb   rb   rc   /test_write_read_attribute_named_key_ids_graphmlv  s@   






 $z@TestWriteGraphML.test_write_read_attribute_named_key_ids_graphmlc                 C   s  ddl m} | j}t }| j||dd |d t|}|d t	|
 |
 s/J t| | s:J t|jdd|jddsIJ | jd ||}t| }t|dksaJ dd |d d	 D }t|d	kstJ d
|d v s|J d
|d v sJ d S )Nr   r   Tinfer_numeric_typesrk   r   c                 S   r   rb   r   r   rb   rb   rc   r     r   zSTestWriteGraphML.test_write_read_attribute_numeric_type_graphml.<locals>.<listcomp>r   )z	attr.typedoubler8   )r   r   rP   rA   rB   r   rq   r;   rm   r   ro   r   rp   rQ   r   r   r   )rt   r   r   ra   ru   r  r  r   rb   rb   rc   .test_write_read_attribute_numeric_type_graphml  s$   


z?TestWriteGraphML.test_write_read_attribute_numeric_type_graphmlc                 C   s   t  }|ddg t \}}| || t |}| s"J t|j	dd|j	dds1J |j
|j
ks9J t| t| dS )zWriting keys as edge id attributes means keys become strings.
        The original keys are stored as data, so read them back in
        if `str(key) == edge_id`
        This allows the adjacency to remain the same.
        r   r   r   )r   r   r   Tr   N)r;   rW   r@   tempfilemkstempr   rm   is_multigraphr   rp   r   oscloseunlinkrt   r   fdfnameru   rb   rb   rc   test_more_multigraph_keys  s   

z*TestWriteGraphML.test_more_multigraph_keysc                 C   s   t jdd}|jdddd t |g d |jdddd	 d
di|jd< ddi|jd< t }| || |	d t j
|td}t| | sMJ t| | sXJ |j|jks`J d S )NFred)namer8   r   )r   r   )r   r8   r   r   r   r   r9   r   r   r   r       edge_defaultr   r   )r;   rS   r>   add_pathr?   rG   rA   rB   r   rq   rm   r   r   ro   r   rp   r   rb   rb   rc   test_default_attribute  s   
z'TestWriteGraphML.test_default_attributec                 C   s   t  }|jddd |jddd |jdddd |jdddd t }| || |d t |}|j	d d r?J |j	d d dksJJ |j
d d rSJ |j
d d dks^J d S )	Nr   Fspecialr   r   r  r   r   r   r   r   r8   r;   rW   r>   r?   rA   rB   r   rq   rm   ro   rp   r   rb   rb   rc   test_mixed_type_attributes  s   

z+TestWriteGraphML.test_mixed_type_attributesc                 C   s   t  }|jddd |jddd |jdddd |jdddd t }| || |d t |}|j	d d dksAJ |j	d d dksLJ |j
d d dksWJ |j
d d dksbJ d S )	Nr   hellor  r   r   r  r  r  r   r   rb   rb   rc   %test_str_number_mixed_type_attributes  s   

z6TestWriteGraphML.test_str_number_mixed_type_attributesc                 C   s   t d}t }|jd|dd |jddd |jdd|dd |jdddd t }| 	|| |
d t|}|jd d	 dksLJ |jd d	 dksWJ |jd
 d	 dksbJ |jd d	 dksmJ d S )Nnumpyr   r   r  r   r8   r   r   r  r  r  )r   r   r;   rW   r>   int64r?   rA   rB   r   rq   rm   ro   rp   )rt   npr   ra   ru   rb   rb   rc   %test_mixed_int_type_number_attributes  s   


z6TestWriteGraphML.test_mixed_int_type_number_attributesc                 C   sx   t d}|d}tddd|ifg}t \}}| || tj|t	d}|j
|j
ks0J t| t| d S )Nr$  333333@r8   r   r    r   )r   r   float_r;   rS   r  r  r   rm   r   r   r  r  r  )rt   r&  wtr   r  r  ru   rb   rb   rc   test_numpy_float  s   


z!TestWriteGraphML.test_numpy_floatc                 C   s   t  }|ddg t \}}| || t |}| r"J t j|dd}| s/J t	| t
| |ddd t \}}| || t |}| sWJ t j|dd}| sdJ t	| t
| d S )Nr  )r   cr   Tr   r   r   ze-id)r;   rW   r@   r  r  r   rm   r  r  r  r  r?   r  rb   rb   rc   test_multigraph_to_graph  s&   




z)TestWriteGraphML.test_multigraph_to_graphc                 C   s  ddl m} t }|g d dd |jD }t||d t \}}| j	||dd tj
|dd}t|}t| | sEJ t| | sPJ t||d t|jd	d
|jd	d
sfJ ||}t| }	t|	dksxJ dd | dD }
t|
t| ksJ d|}t|}t| t| ksJ t| t| ksJ t||d t|jd	d
|jd	d
sJ t| t| d S )Nr   r   )r   r   r   r,  r   r,  c                 S      i | ]}|t |qS rb   r   r   erb   rb   rc   r   3      zOTestWriteGraphML.test_write_generate_edge_id_from_attribute.<locals>.<dictcomp>eidedge_id_from_attributer   Trk   r   c                 S      g | ]}|j d  qS r
   attribr   edgerb   rb   rc   r   E      zOTestWriteGraphML.test_write_generate_edge_id_from_attribute.<locals>.<listcomp>..//{http://graphml.graphdrawing.org/xmlns}edger   )r   r   r;   rS   r@   rp   set_edge_attributesr  r  r   generate_graphmlrm   r   ro   r   r   r   r   findallrn   valuesjoinrr   r  r  r  )rt   r   r   edge_attributesr  r  	generatorru   treer  edge_idsrl   r  rb   rb   rc   *test_write_generate_edge_id_from_attribute.  s<   



z;TestWriteGraphML.test_write_generate_edge_id_from_attributec                 C   s(  ddl m} t }|g d dd |jD }t||d t \}}| j	||dd tj
|dd}t|}| s@J tj|dd	}| sMJ t| | sXJ t| | scJ td
d |jddD t| ksxJ tdd |jddD t| ksJ ||}t| }	t|	dksJ dd | dD }
t|
t| ksJ d|}t|}| sJ t| | sJ t| | sJ tdd |jddD t| ksJ tdd |jddD t| ksJ t| t| d S )Nr   r   )r.  r/  r0  r.  c                 S   r1  rb   r   r2  rb   rb   rc   r   _  r4  zZTestWriteGraphML.test_multigraph_write_generate_edge_id_from_attribute.<locals>.<dictcomp>r5  r6  Tr   c                 s        | ]\}}}| d V  qdS r5  Ngetr   uvrl   rb   rb   rc   r   n      zYTestWriteGraphML.test_multigraph_write_generate_edge_id_from_attribute.<locals>.<genexpr>rk   c                 s       | ]\}}}|V  qd S r   rb   r   rN  rO  r   rb   rb   rc   r   r      r   r   c                 S   r8  r
   r9  r;  rb   rb   rc   r   y  r=  zZTestWriteGraphML.test_multigraph_write_generate_edge_id_from_attribute.<locals>.<listcomp>r>  r   c                 s   rI  rJ  rK  rM  rb   rb   rc   r     rP  c                 s   rQ  r   rb   rR  rb   rb   rc   r     rS  )r   r   r;   rW   r@   rp   r?  r  r  r   r@  rm   r  r   ro   r   rn   rB  r   r   r   rA  rC  rr   r  r  r  )rt   r   r   rD  r  r  rE  ru   rF  r  rG  graphml_datar  rb   rb   rc   5test_multigraph_write_generate_edge_id_from_attributeZ  sT   






zFTestWriteGraphML.test_multigraph_write_generate_edge_id_from_attributec           	      C      t d}|d}tddd|ifg}t \}}| || tj|t	d}|j
|j
ks0J |d d d }|d d d }|t j|ddksKJ t||jksTJ t|tks\J t| t| d S 	Nr$  r(  r8   r   r    r   gư>)abs)r   r   float64r;   rS   r  r  r   rm   r   rp   approxtypefloatr  r  r  	rt   r&  r*  r   r  r  ru   wtGwtHrb   rb   rc   test_numpy_float64     


z#TestWriteGraphML.test_numpy_float64c           	      C   rV  rW  )r   r   float32r;   rS   r  r  r   rm   r   rp   rZ  r[  r\  r  r  r  r]  rb   rb   rc   test_numpy_float32  ra  z#TestWriteGraphML.test_numpy_float32c                 C   sr   t d}| j}|d|jd d< t \}}| j||dd t	|}|j
|j
ks-J t| t| d S )Nr$  r'   )r   r   r    Tr  )r   r   rP   rY  rp   r  r  r   r;   rm   r   r  r  r  )rt   r&  r   r  r  ru   rb   rb   rc   test_numpy_float64_inference  s   


z-TestWriteGraphML.test_numpy_float64_inferencec                 C   s   t  }tdtd td }tdtd td }t}|j|d|d t \}}| || t j||d	}|j	|j	ksAJ t
| t
| d S )
Ni(	  {   i  i  i  iD  	Radiohead)r	   r   )r;   rS   chrr   r?   r  r  r   rm   r   r  r  r  )rt   r   name1name2r   r  r  ru   rb   rb   rc   test_unicode_attributes  s   
z(TestWriteGraphML.test_unicode_attributesc                 C   sr   dd l }tdd}||}t }||jd< t }| || |	d t
|}|jd |jd ks7J d S )Nr   z{"a": "123"})r   r   )jsonr   dumpsr;   rS   rG   rA   rB   r   rq   rm   )rt   rk  r   sar   ra   ru   rb   rb   rc   test_unicode_escape  s   




z$TestWriteGraphML.test_unicode_escapeN)re   rf   rg   staticmethodr;   r   r   rh   rd   r   r   r   r   r  r
  r  r  r!  r#  r'  r+  r-  rH  rU  r`  rc  rd  rj  rn  rb   rb   rb   rc   r   G  s0    

-,:r   c                   @   s"   e Zd ZeejZedd ZdS )TestXMLGraphMLc                 C   s   t   d S r   )r   rd   )r`   rb   rb   rc   rd     s   zTestXMLGraphML.setup_classN)	re   rf   rg   ro  r;   r   r   rh   rd   rb   rb   rb   rc   rp    s    
rp  c                  C   sl   t d t } | jdg dd t }t jtdd t	| | W d   dS 1 s/w   Y  dS )qTest that a detailed exception is raised when an attribute is of a type
    not supported by GraphML, e.g. a listr   r   r   r8   r   my_list_attributeGraphML does not supportmatchN)
r   r   r;   rS   r>   rA   rB   r   	TypeErrorr   r   ra   rb   rb   rc   1test_exception_for_unsupported_datatype_node_attr  s   
"rz  c                  C   sn   t d t } | jddg dd t }t jtdd t	| | W d   dS 1 s0w   Y  dS )	rq  r   r   r8   rr  rs  ru  rv  N)
r   r   r;   rS   r?   rA   rB   r   rx  r   ry  rb   rb   rc   1test_exception_for_unsupported_datatype_edge_attr  s   
"r{  c                  C   sh   t d t } g d| jd< t }t jtdd t	| | W d   dS 1 s-w   Y  dS )rq  r   rr  rt  ru  rv  N)
r   r   r;   rS   rG   rA   rB   r   rx  r   ry  rb   rb   rc   2test_exception_for_unsupported_datatype_graph_attr  s   
"r|  )rA   r  r  r   networkxr;   networkx.readwrite.graphmlr   networkx.utilsr   r   r   ri   r   rp  rz  r{  r|  rb   rb   rb   rc   <module>   s2      1         