o
    ]Zh                    @   s   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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>Zn10n0n2fooid)
n1r   r   n3)r   n5)r   n4)r   n6)r   r   )r   n7)r   n8)r   r   )r   Z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   Z	turquoisee0g      ?)r
   weightr   e1e2g       @Ze3Ze4Ze5Z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        ZFoo)Zboolean_attributeZint_attributeZlong_attributeZfloat_attributeZdouble_attributeZ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>
0Zval1Zval2)prop1prop21Zval_oneZ
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nxZDiGraphsimple_directed_graphadd_nodeadd_edgeadd_edges_fromioBytesIOencodesimple_directed_fhattribute_dataattribute_graphgraphattribute_fhZnode_attribute_default_datanode_attribute_default_graphnode_attribute_default_fhZattribute_named_key_ids_dataattribute_named_key_ids_graphattribute_named_key_ids_fhZ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 rL   T/var/www/auris/lib/python3.10/site-packages/networkx/readwrite/tests/test_graphml.pysetup_class   s   
*







zBaseGraphML.setup_classN)__name__
__module____qualname__classmethodrN   rL   rL   rL   rM   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_graphmlr1   sortednodesedgesseekparse_graphmlr(   selfr   HPGrL   rL   rM   !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   )r>   r)   rW   r?   r   rY   r   rZ   r[   r\   r<   r]   rL   rL   rM   #test_read_simple_undirected_graphmlG     z3TestReadGraphML.test_read_simple_undirected_graphmlc                 C   rb   rc   )rB   r)   rW   rC   r   rY   r   rZ   r[   r\   r@   r]   rL   rL   rM   'test_read_undirected_multigraph_graphmlR  re   z7TestReadGraphML.test_read_undirected_multigraph_graphmlc                 C   rb   rc   )rE   r)   rW   rF   r   rY   r   rZ   r[   r\   rD   r]   rL   rL   rM   4test_read_undirected_multigraph_no_multiedge_graphml]  re   zDTestReadGraphML.test_read_undirected_multigraph_no_multiedge_graphmlc                 C   rb   rc   )rH   r)   rW   rI   r   rY   r   rZ   r[   r\   rG   r]   rL   rL   rM   ?test_read_undirected_multigraph_only_ids_for_multiedges_graphmlh  re   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 rT   )r3   r)   rW   r5   r   rY   rX   rZ   zipr[   r\   r2   )r^   r   r_   geheabr`   rL   rL   rM   test_read_attribute_graphmls  s    "z+TestReadGraphML.test_read_attribute_graphmlc                 C   s.   | j }t| j}|jd |jd ksJ d S )Nr   )r6   r)   rW   r7   r4   )r^   r   r_   rL   rL   rM   #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   	r.   r/   r0   pytestraisesr)   NetworkXErrorrW   r\   r^   srK   rL   rL   rM    test_directed_edge_in_undirected     z0TestReadGraphML.test_directed_edge_in_undirectedc                 C   rp   )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   rq   ru   rL   rL   rM    test_undirected_edge_in_directed  rx   z0TestReadGraphML.test_undirected_edge_in_directedc                 C   rp   )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   rq   ru   rL   rL   rM   test_key_raise  s   zTestReadGraphML.test_key_raisec                 C   rp   )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   rq   ru   rL   rL   rM   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   )	r.   r/   r0   r)   rW   rX   rZ   r[   r\   r^   rv   rK   r   expectedr_   rL   rL   rM   test_multigraph_keys  s   


z$TestReadGraphML.test_multigraph_keysc                 C   sH  t  }|d |d |dddddifddddifdddd	d
fdddddifdddddifdddddd
fg t }t || |d t j|t	d}t
|jddd|jdddsdJ |j|jkslJ 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
        r&      )r&   r   keyZ	data_key1r
   Zdata_id2Z	data_key3Zdata_id3)r   r
   g   Z	data_key4h   Zdata_id5i   Z	data_key6Zdata_id7r   	node_typeT)rV   r}   c                 S   (   i | ]\}}t |d d | D qS )c                 S   r   )c                 S   s   i | ]	\}}t ||qS rL   str).0ZekeyddrL   rL   rM   
<dictcomp>  s    zWTestReadGraphML.test_preserve_multi_edge_data.<locals>.<dictcomp>.<dictcomp>.<dictcomp>r   items)r   ZnbrZkey_dictrL   rL   rM   r     s    zLTestReadGraphML.test_preserve_multi_edge_data.<locals>.<dictcomp>.<dictcomp>r   )r   nodeZnbr_dictrL   rL   rM   r     s    zATestReadGraphML.test_preserve_multi_edge_data.<locals>.<dictcomp>)r   Zedge_key_typeN)r)   rA   r+   r-   r.   r/   write_graphmlr[   rW   intr   rZ   _adjr   r   readr\   )r^   r   rK   r_   ZGadjZHHZ	string_fhrL   rL   rM   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Zforce_multigraph)r   r   r   r   r   )r   labelr$   2r   3Z
shape_typeZ	rectanglezcom.yworks.flowchart.terminatordescriptionzdescription
line1
line2r   r
   )r.   r/   r0   r)   rW   listrZ   Zhas_edgerY   r[   r\   )r^   rV   rK   r   r_   rL   rL   rM   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   )r.   r/   r0   r)   rW   r\   rY   )r^   rv   rK   r   r_   r4   rL   rL   rM   	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   )
r.   r/   r0   r)   rW   r\   rY   rr   rs   rt   )	r^   ZgoodbadZuglyrv   rK   r   r_   r4   rL   rL   rM   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 rL   rL   )r   _xrL   rL   rM   
<listcomp>(      zDTestReadGraphML.test_read_attributes_with_groups.<locals>.<listcomp>TrU   	   ZCustomProperty )r.   r/   r0   r)   rW   rY   len)r^   rV   rK   r   Z	node_datarL   rL   rM    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   Zcudfversioni  TrU   r   )	r.   r/   r0   r)   rW   rX   rY   r[   r\   r~   rL   rL   rM   test_long_attribute_type-  s   


z(TestReadGraphML.test_long_attribute_typeN)rO   rP   rQ   ra   rd   rf   rg   rh   rn   ro   rw   ry   rz   r{   r   r   r   r   r   r   r   rL   rL   rL   rM   rS   9  s,    - +3  &rS   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)S )*TestWriteGraphMLc                 C   s   t   td}d S )N
lxml.etree)r   rN   rr   importorskip)rJ   r   rL   rL   rM   rN   H  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 rc   )Z
lxml.etreer)   r   write_graphml_lxmlImportErrorwrite_graphml_xml)r^   ZlxmlrL   rL   rM   test_write_interfaceM  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   TrU   r*   r4   r.   r/   writerr[   r)   rW   rX   rY   rZ   r1   r^   r   rK   r_   rL   rL   rM   'test_write_read_simple_directed_graphmlU  s   


$z8TestWriteGraphML.test_write_read_simple_directed_graphmlc                 C   s&   t  }| j}| }|||g d S N)r   r*   copyZ
add_graphs)r^   Zgmlwr   r_   rL   rL   rM   test_GraphMLWriter_add_graphsa  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   r$   r
   F)Zprettyprintr   TrU   r   r   rL   rL   rM   %test_write_read_simple_no_prettyprintg  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)Znamed_key_idsrU      c                 S      g | ]}|  qS rL   r   r   childrL   rL   rM   r     r   zTTestWriteGraphML.test_write_read_attribute_named_key_ids_graphml.<locals>.<listcomp>   )r
   r%   )	attr.namer%   )r
   r#   r&   )r   r#   )r
   r"   r   )r   r"   c                 s       | ]	\}}||kV  qd S r   rL   )r   r   r   rL   rL   rM   	<genexpr>      zSTestWriteGraphML.test_write_read_attribute_named_key_ids_graphml.<locals>.<genexpr>c                 s   r   r   rL   )r   r   r   rL   rL   rM   r     r   )xml.etree.ElementTreer   r8   r.   r/   r   r[   r)   rW   r   rY   r   rZ   r9   r   getrootr   r   allri   )r^   r   r   rK   r_   xmlchildrenr}   Zdefault_behavior_fhZnamed_key_ids_behavior_fhJrL   rL   rM   /test_write_read_attribute_named_key_ids_graphmlt  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Zinfer_numeric_typesrU   r   c                 S   r   rL   r   r   rL   rL   rM   r     r   zSTestWriteGraphML.test_write_read_attribute_numeric_type_graphml.<locals>.<listcomp>r   )z	attr.typedoubler&   )r   r   r:   r.   r/   r   r[   r)   rW   r   rY   r   rZ   r;   r   r   r   )r^   r   r   rK   r_   r   r   r}   rL   rL   rM   .test_write_read_attribute_numeric_type_graphml  s$   


z?TestWriteGraphML.test_write_read_attribute_numeric_type_graphmlc                 C   sr   t  }|ddg |d }| || t |}| s J t|jdd|jdds/J |j|jks7J 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.
        rl   rm   r   )rl   rm   r   test.graphmlTr|   N)	r)   rA   r-   r   rW   is_multigraphr   rZ   r   r^   tmp_pathr   fnamer_   rL   rL   rM   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 )NZFred)namer&   r   )r   r   )r   r&   r   r   r   r   r'   r   r   r   r      Zedge_defaultr   r   )r)   r=   r+   Zadd_pathr,   r4   r.   r/   r   r[   rW   r   r   rY   r   rZ   r   rL   rL   rM   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   r&   r)   rA   r+   r,   r.   r/   r   r[   rW   rY   rZ   r   rL   rL   rM   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   Zhellor   r   r   r   r   r   r   r   rL   rL   rM   %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   r&   r   r   r   r   r   )rr   r   r)   rA   r+   Zint64r,   r.   r/   r   r[   rW   rY   rZ   )r^   npr   rK   r_   rL   rL   rM   %test_mixed_int_type_number_attributes  s   


z6TestWriteGraphML.test_mixed_int_type_number_attributesc                 C   s   t  }|ddg |d }| || t |}| r J t j|dd}| s-J |ddd |d }| || t |}| sIJ t j|dd}| sVJ d S )	Nr   )rm   cr   r   Tr   rl   rm   ze-id)r)   rA   r-   r   rW   r   r,   r   rL   rL   rM   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 |d }| j||dd tj|dd}t	|}t
| | sCJ t| | sNJ t||d	 t|jd
d|jd
dsdJ ||}t| }	t|	dksvJ 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 d S )Nr   r   )rl   rm   rm   r   rl   r   c                 S      i | ]}|t |qS rL   r   r   erL   rL   rM   r          zOTestWriteGraphML.test_write_generate_edge_id_from_attribute.<locals>.<dictcomp>eidr   Zedge_id_from_attributer
   TrU   r   c                 S      g | ]}|j d  qS r	   Zattribr   edgerL   rL   rM   r   2      zOTestWriteGraphML.test_write_generate_edge_id_from_attribute.<locals>.<listcomp>..//{http://graphml.graphdrawing.org/xmlns}edger   )r   r   r)   r=   r-   rZ   set_edge_attributesr   generate_graphmlrW   r   rY   r   r   r   r   findallrX   valuesjoinr\   )r^   r   r   r   edge_attributesr   	generatorr_   treer   edge_idsrV   r   rL   rL   rM   *test_write_generate_edge_id_from_attribute  s8   


"z;TestWriteGraphML.test_write_generate_edge_id_from_attributec                 C   s  ddl m} t }|g d dd |jD }t||d |d }| j||dd tj|dd}t	|}|
 s>J tj	|d	d
}|
 sKJ t| | sVJ t| | saJ tdd |jd	dD t| ksvJ 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 d S )Nr   r   )r   r   r   r   c                 S   r   rL   r   r   rL   rL   rM   r   I  r   zZTestWriteGraphML.test_multigraph_write_generate_edge_id_from_attribute.<locals>.<dictcomp>r   r   r   Tr   c                 s        | ]\}}}| d V  qdS r   Ngetr   uvrV   rL   rL   rM   r   X      zYTestWriteGraphML.test_multigraph_write_generate_edge_id_from_attribute.<locals>.<genexpr>rU   c                 s       | ]\}}}|V  qd S r   rL   r   r  r  r   rL   rL   rM   r   \      r|   r   c                 S   r   r	   r   r   rL   rL   rM   r   c  r   zZTestWriteGraphML.test_multigraph_write_generate_edge_id_from_attribute.<locals>.<listcomp>r   r   c                 s   r   r  r  r  rL   rL   rM   r   s  r  c                 s   r  r   rL   r	  rL   rL   rM   r   w  r
  )r   r   r)   rA   r-   rZ   r   r   r   rW   r   r   rY   r   rX   r   r   r   r   r   r   r\   )r^   r   r   r   r   r   r   r_   r   r   r   Zgraphml_datar   rL   rL   rM   5test_multigraph_write_generate_edge_id_from_attributeD  sP   





zFTestWriteGraphML.test_multigraph_write_generate_edge_id_from_attributec           	      C      t d}|d}tddd|ifg}|d }| || tj|td}|j|jks.J |d d d }|d d d }|t j	|dd	ksIJ t
||jksRJ t
|tksZJ d S 
Nr   g333333@r&   r   r   r   r   gư>)abs)rr   r   float64r)   r=   r   rW   r   rZ   approxtypefloat	r^   r   r   wtr   r   r_   ZwtGZwtHrL   rL   rM   test_numpy_float64{     

z#TestWriteGraphML.test_numpy_float64c           	      C   r  r  )rr   r   Zfloat32r)   r=   r   rW   r   rZ   r  r  r  r  rL   rL   rM   test_numpy_float32  r  z#TestWriteGraphML.test_numpy_float32c                 C   sZ   t d}| j}|d|jd d< |d }| j||dd t|}|j|jks+J d S )Nr   r    )r   r   r   r   Tr   )	rr   r   r:   r  rZ   r   r)   rW   r   )r^   r   r   r   r   r_   rL   rL   rM   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 |d	 }| || t j||d
}|j|jks?J d S )Ni(	  {   i  i  i  iD  Z	Radiohead)r   r   r   )r)   r=   chrr   r,   r   rW   r   )r^   r   r   Zname1Zname2r   r   r_   rL   rL   rM   test_unicode_attributes  s   z(TestWriteGraphML.test_unicode_attributesc                 C   sp   dd l }ddi}||}t }||jd< t }| || |d t	|}|jd |jd ks6J d S )Nr   rl   z{"a": "123"}r   )
jsondumpsr)   r=   r4   r.   r/   r   r[   rW   )r^   r  rl   sar   rK   r_   rL   rL   rM   test_unicode_escape  s   



z$TestWriteGraphML.test_unicode_escapeN)rO   rP   rQ   staticmethodr)   r   r   rR   rN   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  rL   rL   rL   rM   r   E  s.    

-)7	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   rN   )rJ   rL   rL   rM   rN     s   zTestXMLGraphML.setup_classN)	rO   rP   rQ   r   r)   r   r   rR   rN   rL   rL   rL   rM   r!    s    
r!  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   r&   r   my_list_attributeGraphML does not supportmatchN)
rr   r   r)   r=   r+   r.   r/   rs   	TypeErrorr   r   rK   rL   rL   rM   1test_exception_for_unsupported_datatype_node_attr  s   
"r+  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 )	r"  r   r   r&   r#  r$  r&  r'  N)
rr   r   r)   r=   r,   r.   r/   rs   r)  r   r*  rL   rL   rM   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 )r"  r   r#  r%  r&  r'  N)
rr   r   r)   r=   r4   r.   r/   rs   r)  r   r*  rL   rL   rM   2test_exception_for_unsupported_datatype_graph_attr  s   
"r-  c                  C   sR   d} t | d}t|}|jd dddksJ |jd dd	dks'J d
S )zPTests that a GraphML string with an empty attribute can be parsed
    correctly.a  <?xml version='1.0' encoding='utf-8'?>
    <graphml>
      <key id="d1" for="node" attr.name="foo" attr.type="string"/>
      <key id="d2" for="node" attr.name="bar" attr.type="string"/>
      <graph>
        <node id="0">
          <data key="d1">aaa</data>
          <data key="d2">bbb</data>
        </node>
        <node id="1">
          <data key="d1">ccc</data>
          <data key="d2"></data>
        </node>
      </graph>
    </graphml>r   r!   Zaaabbb)r   barr$   cccr   N)r.   r/   r0   r)   rW   rY   )rv   rK   r   rL   rL   rM   test_empty_attribute  s
   
r1  )r.   rr   Znetworkxr)   Znetworkx.readwrite.graphmlr   Znetworkx.utilsr   r   r   rS   r   r!  r+  r,  r-  r1  rL   rL   rL   rM   <module>   s.      1        w