1 package org.molwind.graph; 2 3 /* 4 * This file is part of Molwind. 5 * 6 * Molwind is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * Molwind is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with Molwind. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 import org.molwind.model.Relationship; 21 import org.molwind.model.WorldEntity; 22 23 /** 24 * EntityGraph stores graphs of entities (= vertices) and relationships 25 * (= edges) among those. 26 * 27 * @author <a href="mailto:oliver.karch@molwind.org">Oliver Karch</a> 28 * @version 1.0 29 */ 30 public interface EntityGraph extends Iterable { 31 32 /** 33 * Adds an entity i.e. vertex to graph. If the vertex id is existing 34 * already the vertex is replaced. 35 * 36 * @param vertexId 37 * the vertex id 38 * @param entity 39 * the entity to add 40 */ 41 void addEntity(String vertexId, WorldEntity entity); 42 43 /** 44 * Finds the given vertex id. 45 * 46 * @param vertexId 47 * the vertex id 48 * @return 49 * the entity if it was found, null otherwise 50 */ 51 WorldEntity findEntity(String vertexId); 52 53 /** 54 * Adds a relationship edge between vertex vertexId1 and vertex vertexId2. 55 * For any non-existing vertex a new vertex is created. 56 * 57 * @param vertexId1 58 * the first vertex id 59 * @param vertexId2 60 * the second vertex id 61 * @param relation 62 * the relationship represented by the edge 63 */ 64 void addEdge(String vertexId1, String vertexId2, 65 Relationship relation,int weight); 66 67 /** 68 * Analyzes the entity graph using the given analysis strategy. 69 * 70 * @param analyzer 71 * the analysis strategy 72 */ 73 void analyze(EntityGraphAnalyzer analyzer); 74 75 76 77 }