001/* Copyright (C) 2013 TU Dortmund
002 * This file is part of AutomataLib, http://www.automatalib.net/.
003 * 
004 * AutomataLib is free software; you can redistribute it and/or
005 * modify it under the terms of the GNU Lesser General Public
006 * License version 3.0 as published by the Free Software Foundation.
007 * 
008 * AutomataLib is distributed in the hope that it will be useful,
009 * but WITHOUT ANY WARRANTY; without even the implied warranty of
010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
011 * Lesser General Public License for more details.
012 * 
013 * You should have received a copy of the GNU Lesser General Public
014 * License along with AutomataLib; if not, see
015 * http://www.gnu.de/documents/lgpl.en.html.
016 */
017package net.automatalib.graphs;
018
019/**
020 * A graph that allows modification. Note that this interface only exposes
021 * methods for extending a graph. If also destructive modifications should be performed,
022 * {@link ShrinkableGraph} is the adequate interface.
023 * 
024 * @author Malte Isberner <malte.isberner@gmail.com>
025 *
026 * @param <N> node class
027 * @param <E> edge class
028 * @param <NP> node property class
029 * @param <EP> edge property class
030 */
031public interface MutableGraph<N, E, NP, EP> extends UniversalGraph<N,E,NP,EP> {
032        
033        /**
034         * Adds a new node with default properties to the graph.
035         * This method behaves equivalently to the below {@link #addNode(Object)} with
036         * a <code>null</code> parameter.
037         * @return the newly inserted node
038         */
039        public N addNode();
040        
041        /**
042         * Adds a new node to the graph.
043         * @param property the property for the new node
044         * @return the newly inserted node
045         */
046        public N addNode(NP property);
047        
048        /**
049         * Inserts an edge in the graph, with the default property.
050         * Calling this method should be equivalent to invoking
051         * {@link #connect(Object, Object, Object)} with a <tt>null</tt>
052         * property value.
053         * @param source the source node
054         * @param target the target node
055         * @return the edge connecting the given nodes
056         */
057        public E connect(N source, N target);
058        
059        /**
060         * Inserts an edge in the graph.
061         * @param source the source node of the edge
062         * @param target the target node of the edge
063         * @param property the property of the edge
064         * @return the newly inserted edge
065         */
066        public E connect(N source, N target, EP property);
067        
068        public void setNodeProperty(N node, NP property);
069        public void setEdgeProperty(E edge, EP property);
070        
071}