U
    :vf                    @   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   sD  d| _ t | _| jd | jjdddd | jdd | jddd	d
ddddddg
 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/d0| jjd< | jd | jd" | jjdd"dd t| j	d| _d1| _t | _| jjd2d3d4d5 | jjd6d7d4d5 | jjd2d6d8d9 t| j	d}|| _d:| _t | _| jjdd;d< | jjd"d%d< | jjdd"d;d< | jjd"d"d d< t| j	d}|| _d=| _t | _| jd | jjdddd | jddg t| j	d}|| _d>| _t | _| jd | jjdddd | jjd"dd#d | jjdd"d$d t| j	d}|| _d?| _ t | _!| j!d | j!jdddd | j!jd"dd#d | j!jddd$d t| j 	d}|| _"d@| _#t | _$| j$d | j$dd | j$jd"dd#d | j$jdd"d$d t| j#	d}|| _%d S )ANa  <?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   Zbluer   Z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>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 rH   I/tmp/pip-unpacked-wheel-_lngutwb/networkx/readwrite/tests/test_graphml.pysetup_class   s    
*






zBaseGraphML.setup_classN)__name__
__module____qualname__classmethodrJ   rH   rH   rH   rI   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.tt| t| ksJtt|jddt|jddksnt| jd t	| j
}t| t| kstt| t| kstt|jddt|jddkstd S NTdatar   )r&   r%   read_graphmlr-   sortednodesAssertionErroredgesseekparse_graphmlr$   selfr   HPGrH   rH   rI   !test_read_simple_directed_graphml<  s    $z1TestReadGraphML.test_read_simple_directed_graphmlc                 C   s   | j }t| j}t| | s(tt| | s>t| j	d t
| j}t| | sltt| | std S Nr   )r:   r%   rS   r;   r   rU   rV   r   rW   rX   rY   r8   rZ   rH   rH   rI   #test_read_simple_undirected_graphmlI  s    z3TestReadGraphML.test_read_simple_undirected_graphmlc                 C   s   | j }t| j}t| | s(tt| | s>t| j	d t
| j}t| | sltt| | std S r_   )r>   r%   rS   r?   r   rU   rV   r   rW   rX   rY   r<   rZ   rH   rH   rI   'test_read_undirected_multigraph_graphmlT  s    z7TestReadGraphML.test_read_undirected_multigraph_graphmlc                 C   s   | j }t| j}t| | s(tt| | s>t| j	d t
| j}t| | sltt| | std S r_   )rA   r%   rS   rB   r   rU   rV   r   rW   rX   rY   r@   rZ   rH   rH   rI   4test_read_undirected_multigraph_no_multiedge_graphml_  s    zDTestReadGraphML.test_read_undirected_multigraph_no_multiedge_graphmlc                 C   s   | j }t| j}t| | s(tt| | s>t| j	d t
| j}t| | sltt| | std S r_   )rD   r%   rS   rE   r   rU   rV   r   rW   rX   rY   rC   rZ   rH   rH   rI   ?test_read_undirected_multigraph_only_ids_for_multiedges_graphmlj  s    zOTestReadGraphML.test_read_undirected_multigraph_only_ids_for_multiedges_graphmlc                 C   s   | j }t| j}t|dt|jdds2tt|jdd}t|jdd}t	||D ]\}}||ks\tq\| j
d t| j}t|dt|jddkstt|jdd}t|jdd}t	||D ]\}}||kstqd S rP   )r/   r%   rS   r1   r   rU   rT   rV   rW   ziprX   rY   r.   )r[   r   r\   geheabr]   rH   rH   rI   test_read_attribute_graphmlu  s     "z+TestReadGraphML.test_read_attribute_graphmlc                 C   s.   | j }t| j}|jd |jd ks*td S )Nr   )r2   r%   rS   r3   r0   rV   )r[   r   r\   rH   rH   rI   #test_node_default_attribute_graphml  s    z3TestReadGraphML.test_node_default_attribute_graphmlc                 C   s<   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+   r,   pytestraisesr%   NetworkXErrorrS   rY   r[   srG   rH   rH   rI    test_directed_edge_in_undirected  s    z0TestReadGraphML.test_directed_edge_in_undirectedc                 C   s<   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" 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   rk   ro   rH   rH   rI    test_undirected_edge_in_directed  s    z0TestReadGraphML.test_undirected_edge_in_directedc                 C   s<   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">
  <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   rk   ro   rH   rH   rI   test_key_raise  s    zTestReadGraphML.test_key_raisec                 C   s<   d}t |d}ttjtj| ttjtj| d S )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   rk   ro   rH   rH   rI   test_hyperedge_raise  s    z$TestReadGraphML.test_hyperedge_raisec                 C   sn   d}t |d}t|}ddg}t|jdd|ks>t|d t	|}t|jdd|ksjt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+   r,   r%   rS   rT   rW   rV   rX   rY   r[   rp   rG   r   expectedr\   rH   rH   rI   test_multigraph_keys  s    


z$TestReadGraphML.test_multigraph_keysc                 C   sL  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st|j|jkstdd |j D }|d t j|ttd}||jkst|d | }t j|ttd}||jksHtdS )zf
        Test that data and keys of edges are preserved on consequent
        write and reads
        r"      )r"   rz   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)rR   rv   c                 S   s(   i | ] \}}t |d d | D qS )c                 S   s(   i | ] \}}t |d d | D qS )c                 S   s   i | ]\}}t ||qS rH   str).0ZekeyddrH   rH   rI   
<dictcomp>  s      zWTestReadGraphML.test_preserve_multi_edge_data.<locals>.<dictcomp>.<dictcomp>.<dictcomp>r   items)r   ZnbrZkey_dictrH   rH   rI   r     s    zLTestReadGraphML.test_preserve_multi_edge_data.<locals>.<dictcomp>.<dictcomp>r   )r   nodeZnbr_dictrH   rH   rI   r     s
    zATestReadGraphML.test_preserve_multi_edge_data.<locals>.<dictcomp>)r   Zedge_key_typeN)r%   r=   r'   r)   r*   r+   write_graphmlrX   rS   intr   rW   rV   _adjr   r   readrY   )r[   r   rG   r\   ZGadjZHHZ	string_fhrH   rH   rI   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s8t|jdddd	sLt|j	d d
 dksbt|j	d d
 dksxt|j	d d
 dkst|j	d d dkst|j	d d dkst|j	d d dkst|j	d d dkst|
d t|}t| dgkst|d d d dks,t|j	d d
 dksDt|j	d d
 dks\t|j	d d
 dkstt|j	d d dkst|j	d d dkst|j	d d dkst|j	d d dksttj|dd}t| dgkst|jdddd	st|j	d d
 dks(t|j	d d
 dks@t|j	d d
 dksXtt|}t| dgkszt|d d d dkst|j	d d
 dkst|j	d d
 dkst|j	d d
 dkst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+   r,   r%   rS   listrW   rV   Zhas_edgerU   rX   rY   )r[   rR   rG   r   r\   rH   rH   rI   test_yfiles_extension-  sF    Z


z%TestReadGraphML.test_yfiles_extensionc                 C   s   d}t |d}t|}t|}||fD ]p}|jd d sFt|jd d rXt|jd d rjt|jd d s|t|jd d rt|jd	 d s0tq0d 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+   r,   r%   rS   rY   rU   rV   )r[   rp   rG   r   r\   r0   rH   rH   rI   	test_bool  s    

zTestReadGraphML.test_boolc           	      C   s   d}d}d}||fD ]H}t |d}t|}t|}||fD ]}|jd d sDtqDq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+   r,   r%   rS   rY   rU   rV   rl   rm   rn   )	r[   ZgoodbadZuglyrp   rG   r   r\   r0   rH   rH   rI   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sDt|D ]}|d d	ksHtqHd 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 rH   rH   )r   _xrH   rH   rI   
<listcomp>*  s     zDTestReadGraphML.test_read_attributes_with_groups.<locals>.<listcomp>TrQ   	   ZCustomProperty )r*   r+   r,   r%   rS   rU   lenrV   )r[   rR   rG   r   Z	node_datarH   rH   rI    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sDt|d t	|}t|jdd|kspt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  TrQ   r   )
r*   r+   r,   r%   rS   rT   rU   rV   rX   rY   rw   rH   rH   rI   test_long_attribute_type/  s    


z(TestReadGraphML.test_long_attribute_typeN)rK   rL   rM   r^   r`   ra   rb   rc   ri   rj   rq   rr   rs   rt   ry   r   r   r   r   r   r   rH   rH   rH   rI   rO   ;  s*   - +3  &rO   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   rJ   rl   importorskip)rF   r   rH   rH   rI   rJ   J  s    zTestWriteGraphML.setup_classc                 C   sF   zdd l }tjtjkstW n$ tk
r@   tjtjks<tY nX d S r_   )Z
lxml.etreer%   r   write_graphml_lxmlrV   ImportErrorwrite_graphml_xml)r[   lxmlrH   rH   rI   test_write_interfaceO  s
    z%TestWriteGraphML.test_write_interfacec                 C   s   | j }d|jd< t }| || |d t|}t|	 t|	 ksTt
t| t| kspt
t|jddt|jddkst
| jd d S )Ntherehir   TrQ   r&   r0   r*   r+   writerrX   r%   rS   rT   rU   rV   rW   r-   r[   r   rG   r\   rH   rH   rI   'test_write_read_simple_directed_graphmlW  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\   rH   rH   rI   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sbt
t| t| ks~t
t|jdd	t|jdd	kst
| jd d S )
Nr   r   r    r
   F)Zprettyprintr   TrQ   r   r   rH   rH   rI   %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^tt| | sttt|jdd|jddst| jd ||}t| }t|dkstdd |d d	 D }t|d	kstd
|d kstd|d ks
td|d kstd|d ks.td|d ks@td|d ksRtt }t|| |d t|}t }	tj||	dd |	d t|	}
tdd t|j
|
j
D sttdd t|j|
jD std S )Nr   parseT)Znamed_key_idsrQ      c                 S   s   g | ]}|  qS rH   r   r   childrH   rH   rI   r     s     zTTestWriteGraphML.test_write_read_attribute_named_key_ids_graphml.<locals>.<listcomp>   )r
   r!   )	attr.namer!   )r
   r   r"   )r   r   )r
   r   rz   )r   r   c                 s   s   | ]\}}||kV  qd S r   rH   )r   r   r   rH   rH   rI   	<genexpr>  s     zSTestWriteGraphML.test_write_read_attribute_named_key_ids_graphml.<locals>.<genexpr>c                 s   s   | ]\}}||kV  qd S r   rH   )r   r   r   rH   rH   rI   r     s     )xml.etree.ElementTreer   r4   r*   r+   r   rX   r%   rS   r   rU   rV   r   rW   r5   r   getrootr   r   allrd   )r[   r   r   rG   r\   xmlchildrenrv   Zdefault_behavior_fhZnamed_key_ids_behavior_fhJrH   rH   rI   /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^tt| | sttt|jdd|jddst| jd ||}t| }t|dkstdd |d d	 D }t|d	kstd
|d kstd
|d ks
td S )Nr   r   TZinfer_numeric_typesrQ   r   c                 S   s   g | ]}|  qS rH   r   r   rH   rH   rI   r     s     zSTestWriteGraphML.test_write_read_attribute_numeric_type_graphml.<locals>.<listcomp>rz   )z	attr.typedoubler"   )r   r   r6   r*   r+   r   rX   r%   rS   r   rU   rV   r   rW   r7   r   r   r   )r[   r   r   rG   r\   r   r   rv   rH   rH   rI   .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 |}| sDtt	|j
dd|j
ddsbt|j|jksrt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.
        rg   rh   rz   )rg   rh   r   Tru   N)r%   r=   r)   tempfilemkstempr   rS   is_multigraphrV   r   rW   r   oscloseunlinkr[   r   fdfnamer\   rH   rH   rI   test_more_multigraph_keys  s    

z*TestWriteGraphML.test_more_multigraph_keysc                 C   s   t jdd}|jdddd t |ddddg |jdddd	 d
di|jd< ddi|jd< t }| || |	d t j
|td}t| | stt| | st|j|jkstd S )NZFred)namer"   r   )r   r   r   rz   r   r#   r   r   r   r      Zedge_defaultr   )r%   r9   r'   Zadd_pathr(   r0   r*   r+   r   rX   rS   r   r   rU   rV   r   rW   r   rH   rH   rI   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~t
|j	d d dkst
|jd d rt
|jd d dkst
d S )	Nr   Fspecialr   r   r   r   r   r   r   r   r"   r%   r=   r'   r(   r*   r+   r   rX   rS   rU   rV   rW   r   rH   rH   rI   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st
|j	d d dkst
|jd d dkst
|jd d dkst
d S )	Nr   Zhellor   r   r   r   r   r   r   r   rH   rH   rI   %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st|jd d	 dkst|jd
 d	 dkst|jd d	 dkstd S )Nnumpyr   r   r   r   r"   rz   r   r   r   r   )rl   r   r%   r=   r'   Zint64r(   r*   r+   r   rX   rS   rU   rV   rW   )r[   npr   rG   r\   rH   rH   rI   %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s`tt| t| d S )Nr   333333@r"   rz   r   r   )rl   r   Zfloat_r%   r9   r   r   r   rS   r   r   rV   r   r   r   )r[   r   wtr   r   r   r\   rH   rH   rI   test_numpy_float  s    


z!TestWriteGraphML.test_numpy_floatc                 C   s   t  }|ddg t \}}| || t |}| rDtt j|dd}| s^tt	
| t	| |ddd t \}}| || t |}| stt j|dd}| stt	
| t	| d S )Nr   )rh   cr   Tr   rg   rh   ze-id)r%   r=   r)   r   r   r   rS   r   rV   r   r   r   r(   r   rH   rH   rI   test_multigraph_to_graph  s&    




z)TestWriteGraphML.test_multigraph_to_graphc                 C   s  ddl m} t }|dddg dd |jD }t||d t \}}| j	||dd	 tj
|dd	}t|}t| | stt| | stt||d
 t|jdd|jddst||}t| }	t|	dkstdd | dD }
t|
t| ks$td|}t|}t| t| ksVtt| t| ksttt||d
 t|jdd|jddstt| t| d S )Nr   r   rg   rh   rh   r   rg   r   c                 S   s   i | ]}|t |qS rH   r   r   erH   rH   rI   r   3  s      zOTestWriteGraphML.test_write_generate_edge_id_from_attribute.<locals>.<dictcomp>eidZedge_id_from_attributer
   TrQ   rz   c                 S   s   g | ]}|j d  qS r	   attribr   ZedgerH   rH   rI   r   E  s   zOTestWriteGraphML.test_write_generate_edge_id_from_attribute.<locals>.<listcomp>..//{http://graphml.graphdrawing.org/xmlns}edger   )r   r   r%   r9   r)   rW   set_edge_attributesr   r   r   generate_graphmlrS   r   rU   rV   r   r   r   r   findallrT   valuesjoinrY   r   r   r   )r[   r   r   edge_attributesr   r   	generatorr\   treer   edge_idsrR   r   rH   rH   rI   *test_write_generate_edge_id_from_attribute.  s<    


 
z;TestWriteGraphML.test_write_generate_edge_id_from_attributec                 C   s:  ddl m} t }|ddddg dd |jD }t||d t \}}| j	||dd	 tj
|dd	}t|}| sttj|d
d}| stt| | stt| | sttdd |jd
dD t| ksttdd |jd
dD t| ks t||}t| }	t|	dksFtdd | dD }
t|
t| ksxtd|}t|}| stt| | stt| | sttdd |jd
dD t| ksttdd |jd
dD t| ks"tt| t| d S )Nr   r   r   r   r   c                 S   s   i | ]}|t |qS rH   r   r   rH   rH   rI   r   _  s      zZTestWriteGraphML.test_multigraph_write_generate_edge_id_from_attribute.<locals>.<dictcomp>r   r   Tr   c                 s   s   | ]\}}}| d V  qdS r   Ngetr   uvrR   rH   rH   rI   r   n  s     zYTestWriteGraphML.test_multigraph_write_generate_edge_id_from_attribute.<locals>.<genexpr>rQ   c                 s   s   | ]\}}}|V  qd S r   rH   r   r   r   r{   rH   rH   rI   r   r  s     ru   rz   c                 S   s   g | ]}|j d  qS r	   r   r   rH   rH   rI   r   y  s   zZTestWriteGraphML.test_multigraph_write_generate_edge_id_from_attribute.<locals>.<listcomp>r   r   c                 s   s   | ]\}}}| d V  qdS r   r   r   rH   rH   rI   r     s     c                 s   s   | ]\}}}|V  qd S r   rH   r   rH   rH   rI   r     s     )r   r   r%   r=   r)   rW   r   r   r   r   r   rS   r   rV   r   rU   r   rT   r   r   r   r   r   r   rY   r   r   r   )r[   r   r   r   r   r   r   r\   r   r   r   Zgraphml_datar   rH   rH   rI   5test_multigraph_write_generate_edge_id_from_attributeZ  sT    




zFTestWriteGraphML.test_multigraph_write_generate_edge_id_from_attributec           	      C   s   t d}|d}tddd|ifg}t \}}| || tj|t	d}|j
|j
ks`t|d d d }|d d d }|t j|ddkstt||jkstt|tkstt| t| d S 	Nr   r   r"   rz   r   r   gư>)abs)rl   r   float64r%   r9   r   r   r   rS   r   rW   rV   approxtypefloatr   r   r   	r[   r   r   r   r   r   r\   ZwtGZwtHrH   rH   rI   test_numpy_float64  s    


z#TestWriteGraphML.test_numpy_float64c           	      C   s   t d}|d}tddd|ifg}t \}}| || tj|t	d}|j
|j
ks`t|d d d }|d d d }|t j|ddkstt||jkstt|tkstt| t| d S r   )rl   r   Zfloat32r%   r9   r   r   r   rS   r   rW   rV   r  r  r  r   r   r   r  rH   rH   rI   test_numpy_float32  s    


z#TestWriteGraphML.test_numpy_float32c                 C   sr   t d}| j}|d|jd d< t \}}| j||dd t	|}|j
|j
ksZtt| t| d S )Nr   r   )r   r   r   Tr   )rl   r   r6   r  rW   r   r   r   r%   rS   r   rV   r   r   r   )r[   r   r   r   r   r\   rH   rH   rI   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st
t| t| d S )
Ni(	  {   i  i  i  iD  Z	Radiohead)r   r   )r%   r9   chrr   r(   r   r   r   rS   r   rV   r   r   r   )r[   r   Zname1Zname2r   r   r   r\   rH   rH   rI   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slt
d S )Nr   rg   z{"a": "123"}r   )jsondumpsr%   r9   r0   r*   r+   r   rX   rS   rV   )r[   r  rg   sar   rG   r\   rH   rH   rI   test_unicode_escape  s    



z$TestWriteGraphML.test_unicode_escapeN)rK   rL   rM   staticmethodr%   r   r   rN   rJ   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r	  r  r  rH   rH   rH   rI   r   G  s.   

-,: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   rJ   )rF   rH   rH   rI   rJ     s    zTestXMLGraphML.setup_classN)	rK   rL   rM   r  r%   r   r   rN   rJ   rH   rH   rH   rI   r    s   
r  c               	   C   sX   t d t } | jddddgd t }t jtdd t	| | W 5 Q R X 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"   rz   )my_list_attributeGraphML does not supportmatchN)
rl   r   r%   r9   r'   r*   r+   rm   	TypeErrorr   r   rG   rH   rH   rI   1test_exception_for_unsupported_datatype_node_attr  s    
r  c               	   C   sZ   t d t } | jdddddgd t }t jtdd t	| | W 5 Q R X dS r  )
rl   r   r%   r9   r(   r*   r+   rm   r  r   r  rH   rH   rI   1test_exception_for_unsupported_datatype_edge_attr  s    
r  c               	   C   sT   t d t } dddg| jd< t }t jtdd t	| | W 5 Q R X dS )	r  r   r   r"   rz   r  r  r  N)
rl   r   r%   r9   r0   r*   r+   rm   r  r   r  rH   rH   rI   2test_exception_for_unsupported_datatype_graph_attr  s    
r  )r*   r   r   rl   Znetworkxr%   Znetworkx.readwrite.graphmlr   Znetworkx.utilsr   r   r   rO   r   r  r  r  r  rH   rH   rH   rI   <module>   s0     1         