Привет, я новичок в JGraphT и пытаюсь импортировать график для работы. Я приложил образец ниже графика и классов, которые я настроил как вершину и ребра. Надеюсь, я делаю это правильно.
Я получаю код ошибки:
Причина: org.jgrapht.nio.ImportException: Не удалось проанализировать GraphML
Причина by: java .lang.IllegalArgumentException: http://www.w3.org/2001/XMLSchema
Я хотел бы получить несколько советов о том, как решить эту проблему и построить график. Нужен ли мне поставщик / поставщик? Мне нужно реализовать набор вершин? Спасибо
Класс вершин:
public class Node {
private String id;
private String lat;
private String lon;
private String name;
private String waypointType;
private String levelId;
private String onStartingRoute;
private String onFinishroute;
private String title;
private String description;
private String relatedRoutes;
public Node() {
}
public Node(String id, String lat, String lon, String name, String waypointType, String levelId, String onStartingRoute, String onFinishroute, String title, String description, String relatedRoutes) {
this.id = id;
this.lat = lat;
this.lon = lon;
this.name = name;
this.waypointType = waypointType;
this.levelId = levelId;
this.onStartingRoute = onStartingRoute;
this.onFinishroute = onFinishroute;
this.title = title;
this.description = description;
this.relatedRoutes = relatedRoutes;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
public String getLon() {
return lon;
}
public void setLon(String lon) {
this.lon = lon;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getWaypointType() {
return waypointType;
}
public void setWaypointType(String waypointType) {
this.waypointType = waypointType;
}
public String getLevelId() {
return levelId;
}
public void setLevelId(String levelId) {
this.levelId = levelId;
}
public String getOnStartingRoute() {
return onStartingRoute;
}
public void setOnStartingRoute(String onStartingRoute) {
this.onStartingRoute = onStartingRoute;
}
public String getOnFinishroute() {
return onFinishroute;
}
public void setOnFinishroute(String onFinishroute) {
this.onFinishroute = onFinishroute;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getRelatedRoutes() {
return relatedRoutes;
}
public void setRelatedRoutes(String relatedRoutes) {
this.relatedRoutes = relatedRoutes;
}
@Override
public String toString() {
return "Node{" +
"id='" + id + '\'' +
", lat='" + lat + '\'' +
", lon='" + lon + '\'' +
", name='" + name + '\'' +
", waypointType='" + waypointType + '\'' +
", levelId='" + levelId + '\'' +
", onStartingRoute='" + onStartingRoute + '\'' +
", onFinishroute='" + onFinishroute + '\'' +
", title='" + title + '\'' +
", description='" + description + '\'' +
", relatedRoutes='" + relatedRoutes + '\'' +
'}';
}
public int hashCode(){
return toString().hashCode();
}
public boolean equals(Object o){
return (o instanceof Node)&&(toString().equals(o.toString()));
}
}
Класс Edge:
public class Edge {
private String edgeId;
private String weight;
private String alpha;
private String intendedpathlonlat;
private String levelId;
private String type;
public Edge() {
}
public Edge(String edgeId, String weight, String alpha, String intendedpathlonlat, String levelId, String type) {
this.edgeId = edgeId;
this.weight = weight;
this.alpha = alpha;
this.intendedpathlonlat = intendedpathlonlat;
this.levelId = levelId;
this.type = type;
}
public String getEdgeId() {
return edgeId;
}
public void setEdgeId(String edgeId) {
this.edgeId = edgeId;
}
public String getWeight() {
return weight;
}
public void setWeight(String weight) {
this.weight = weight;
}
public String getAlpha() {
return alpha;
}
public void setAlpha(String alpha) {
this.alpha = alpha;
}
public String getIntendedpathlonlat() {
return intendedpathlonlat;
}
public void setIntendedpathlonlat(String intendedpathlonlat) {
this.intendedpathlonlat = intendedpathlonlat;
}
public String getLevelId() {
return levelId;
}
public void setLevelId(String levelId) {
this.levelId = levelId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return "Edge{" +
"edgeId='" + edgeId + '\'' +
", weight='" + weight + '\'' +
", alpha='" + alpha + '\'' +
", intendedpathlonlat='" + intendedpathlonlat + '\'' +
", levelId='" + levelId + '\'' +
", type='" + type + '\'' +
'}';
}
public int hashCode(){
return toString().hashCode();
}
public boolean equals(Object o){
return (o instanceof Node)&&(toString().equals(o.toString()));
}
}
Класс графиков:
public class Graph {
private GraphMLImporter<Node, Edge> graphMLImporter = new GraphMLImporter<>();
private Graph<Node, Edge> venueGraph;
private InputStream file;
private Context context;
public void createWayGraph(Context context) throws IOException {
file = context.getApplicationContext().getAssets().open("route.xml");
graphMLImporter.setEdgeWeightAttributeName("weight");
graphMLImporter.setSchemaValidation(true);
graphMLImporter.importGraph(venueGraph, file);
}
}
Пример - GraphML
<?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="edge" id="weight" />
<key attr.name="edgeid" attr.type="string" for="edge" id="edgeid" />
<key attr.name="alpha" attr.type="string" for="edge" id="alpha" />
<key attr.name="intendedpathlonlat" attr.type="string" for="edge" id="intendedpathlonlat" />
<key attr.name="levelid" attr.type="string" for="edge" id="levelid" />
<key attr.name="weight" attr.type="long" for="edge" id="weight" />
<key attr.name="type" attr.type="string" for="edge" id="type" />
<key attr.name="relatedroutes" attr.type="string" for="node" id="relatedroutes" />
<key attr.name="description" attr.type="string" for="node" id="description" />
<key attr.name="title" attr.type="string" for="node" id="title" />
<key attr.name="on_finish_route" attr.type="string" for="node" id="on_finish_route" />
<key attr.name="on_starting_route" attr.type="string" for="node" id="on_starting_route" />
<key attr.name="level_id" attr.type="string" for="node" id="level_id" />
<key attr.name="waypoint_type" attr.type="string" for="node" id="waypoint_type" />
<key attr.name="name" attr.type="string" for="node" id="name" />
<key attr.name="lon" attr.type="string" for="node" id="lon" />
<key attr.name="lat" attr.type="string" for="node" id="lat" />
<graph edgedefault="directed" id="Station">
<node id="L08-022">
<data key="lat">40.69330963</data>
<data key="lon">-73.98752537</data>
<data key="name" />
<data key="waypoint_type">escalator</data>
<data key="level_id">1080000</data>
<data key="on_starting_route" />
<data key="on_finish_route" />
</node>
<node id="L08-023">
<data key="lat">40.69318355</data>
<data key="lon">-73.98755793</data>
<data key="name" />
<data key="waypoint_type">stairs</data>
<data key="level_id">1080000</data>
<data key="on_starting_route" />
<data key="on_finish_route" />
</node>
<node id="L08-024">
<data key="lat">40.69316844</data>
<data key="lon">-73.98755873</data>
<data key="name" />
<data key="waypoint_type">stairs</data>
<data key="level_id">1080000</data>
<data key="on_starting_route" />
<data key="on_finish_route" />
</node>
<edge source="WL10-054" target="L10-029">
<data key="type">floor</data>
<data key="weight">4.22</data>
<data key="levelid">1100000</data>
<data key="intendedpathlonlat">[[-73.9874098324427, 40.6923649788941], [-73.9873852113531, 40.6923542068882], [-73.9874280729066, 40.6923105568907], [-73.9874317515063, 40.6923068106214], [-73.9874565632741, 40.692323527741], [-73.9874098324427, 40.6923649788941]]</data>
<data key="alpha">0.0</data>
<data key="edgeid">RL10-059</data>
</edge>
<edge source="WL10-054" target="WL10-053">
<data key="type">floor</data>
<data key="weight">5.69</data>
<data key="levelid">1100000</data>
<data key="intendedpathlonlat">[[-73.9875185331049, 40.6923375058386], [-73.9875194277605, 40.6923108807062], [-73.9874887802005, 40.6923107720732], [-73.9874280729066, 40.6923105568907], [-73.987427278228, 40.6923378450122], [-73.9875185331049, 40.6923375058386]]</data>
<data key="alpha">0.0</data>
<data key="edgeid">RL10-060</data>
</edge>
</graph>
</graphml>