ch.ethz.sn.visone3.io.graphml.GraphmlSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of netroles-io-engine Show documentation
Show all versions of netroles-io-engine Show documentation
Network file IO engine for netroles library
The newest version!
/*
* This file is part of netroles.
*
* netroles is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* netroles is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with netroles. If not, see .
*/
package ch.ethz.sn.visone3.io.graphml;
import ch.ethz.sn.visone3.io.Source;
import ch.ethz.sn.visone3.io.SourceFormat;
import ch.ethz.sn.visone3.io.impl.SourceFormatImpl;
import ch.ethz.sn.visone3.lang.Mapping;
import ch.ethz.sn.visone3.networks.DyadType;
import ch.ethz.sn.visone3.networks.Network;
import ch.ethz.sn.visone3.networks.NetworkBuilder;
import ch.ethz.sn.visone3.networks.NetworkProvider;
import ch.ethz.sn.visone3.networks.Networks;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.xml.XMLConstants;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
/**
* Read GraphML Graphs.
*
* Supported features:
- Reads one flat graph, no nested objects in node nodes.
*
- Directed or undirected not mixed edges. If the input contains a directed edge all
* edges will be directed. Undirected edges will be present in both directions.
- Simple no
* multi edges, use a weight for multiplicity.
*
*
* <?xml version="1.0" encoding="UTF-8"?>
* <graphml ...>
* <key .../>
* ...
* <graph id="..." edgedefault="..." ...>
* <node id="...">
* <data key="...">...</data>
* ...
* </node>
* ...
* <edge id="..." source="..." target="...">
* <data key="...">...</data>
* ...
* </edge>
* ...
* <data key="...">...</data>
* ...
* </graph>
* <data key="...">...</data>
* ...
* </graphml>
*
*/
public class GraphmlSource implements Source