f163c34065fb3a57a425808a063d05de64bfa8ce
[bgpcep.git] / graph / graph-api / src / main / java / org / opendaylight / graph / ConnectedGraph.java
1 /*
2  * Copyright (c) 2019 Orange.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.graph;
9
10 import java.util.List;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.EdgeKey;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey;
19
20 /**
21  * Connected Graph class is the connected version of the Graph class from the graph yang model.
22  *
23  * <p>
24  * Connected Graph is composed by Connected Vertex, Connected Edges and Prefix. It models Unidirectional Connected
25  * Graph (see graph theory). So, Edge and Connected Edge are unidirectional, thus to connect bi-directionally 2 vertices
26  * Va and Vb, it is necessary to setup 2 edges: Va to Vb and Vb to Va.
27  * <pre>
28  * {@code
29  *        --------------     ---------------------------    --------------
30  *        | Connected  |---->| Connected Edge Va to Vb |--->| Connected  |
31  *   ---->|  Vertex    |     ---------------------------    |  Vertex    |---->
32  *        |            |                                    |            |
33  *        | - Key (Va) |                                    | - Key (Vb) |
34  *   <----| - Vertex   |     ---------------------------    | - Vertex   |<----
35  *        |            |<----| Connected Edge Vb to Va |<---|            |
36  *        --------------     ---------------------------    --------------
37  * }
38  * </pre>
39  *
40  * @author Olivier Dugeon
41  * @author Philippe Niger
42  */
43 public interface ConnectedGraph {
44
45     /**
46      * Returns the Graph associated to this Connected Graph.
47      *
48      * @return Graph
49      */
50     Graph getGraph();
51
52     /**
53      * Returns the list of Connected Vertices that form this graph.
54      *
55      * @return list of Connected Vertices
56      */
57     List<ConnectedVertex> getVertices();
58
59     /**
60      * Returns the Vertex associated to the given key.
61      *
62      * @param key Unique Vertex Identifier
63      * @return Vertex or null if there is no Vertex associated to the given key in this graph
64      */
65     ConnectedVertex getConnectedVertex(Long key);
66
67     /**
68      * Returns the Vertex associated to the given IP address.
69      *
70      * @param address IP address of the Loopback of the Vertex
71      *
72      * @return Vertex or null if there is no Vertex associated to the given IP address in this graph
73      */
74     ConnectedVertex getConnectedVertex(IpAddress address);
75
76     /**
77      * Add Vertex in the Connected Graph. This action will automatically create the associated Connected Vertex and
78      * update the Graph in the DataStore.
79      *
80      * @param vertex Vertex to be added
81      *
82      * @return Connected Vertex associated to the given Vertex
83      */
84     ConnectedVertex addVertex(Vertex vertex);
85
86     /**
87      * Remove the Vertex in the Connected Graph. This action will automatically remove the associated Connected Vertex
88      * and update the Graph in the DataStore.
89      *
90      * @param vertexKey Unique Vertex Identifier
91      */
92     void deleteVertex(VertexKey vertexKey);
93
94     /**
95      * Returns the number of Vertices in the graph.
96      *
97      * @return number of vertices
98      */
99     int getVerticesSize();
100
101     /**
102      * Returns the list of Connected Edges that form this graph.
103      *
104      * @return list of Connected Edges
105      */
106     List<ConnectedEdge> getEdges();
107
108     /**
109      * Returns the Edge associated to the given key.
110      *
111      * @param key Unique Edge Identifier
112      * @return Edge or null if there is no Edge associated to the given key in this graph
113      */
114     ConnectedEdge getConnectedEdge(Long key);
115
116     /**
117      * Returns the Edge associated to the given IP address.
118      *
119      * @param address IP address of the Edge
120      *
121      * @return Edge or null if there is no Edge associated to the given IP address in this graph
122      */
123     ConnectedEdge getConnectedEdge(IpAddress address);
124
125     /**
126      * Add Edge in the Connected Graph. This action will automatically create the associated Connected Edge and
127      * update the Graph in the DataStore.
128      *
129      * @param edge Edge to be added
130      *
131      * @return Connected Edge associated to the given Edge
132      */
133     ConnectedEdge addEdge(Edge edge);
134
135     /**
136      * Remove the Edge in the Connected Graph. This action will automatically remove the associated Connected Edge
137      * and update the Graph in the DataStore.
138      *
139      * @param edgeKey Unique Edge Identifier
140      */
141     void deleteEdge(EdgeKey edgeKey);
142
143     /**
144      * Returns the number of Edges in the graph.
145      *
146      * @return number of edges
147      */
148     int getEdgesSize();
149
150     /**
151      * Returns the list of Prefix that are stored in this graph.
152      *
153      * @return list of Prefix
154      */
155     List<Prefix> getPrefixes();
156
157     /**
158      * Returns the Prefix associated to the given IP prefix.
159      *
160      * @param ippfx IPv4 or IPv6 prefix
161      *
162      * @return Prefix that match the given IPv4 or IPv6 prefix
163      */
164     Prefix getPrefix(IpPrefix ippfx);
165
166     /**
167      * Add Prefix in the Connected Graph. This action will automatically update the Graph in the DataStore.
168      *
169      * @param prefix Prefix to be added
170      *
171      */
172     void addPrefix(Prefix prefix);
173
174     /**
175      * Remove the Prefix in the Connected Graph. This action will automatically update the Graph in the DataStore.
176      *
177      * @param ippfx IPv4 or IPv6 prefix
178      */
179     void deletePrefix(IpPrefix ippfx);
180
181     /**
182      * Clear the Connected Graph by removing all Vertices, Edges and Prefixes. This also remove the associated Graph
183      * in the Datastore.
184      *
185      */
186     void clear();
187
188     /**
189      * Returns the summary of the graph characteristics: number of Vertices, Edges and Prefix.
190      *
191      * @return characteristics of the Graph as a string
192      */
193     String getSummary();
194
195 }