aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime-rete/src/main/java/tools/refinery/viatra/runtime/rete/itc/igraph/IGraphDataSource.java
blob: 9159a6929d426b02561b244724a25235a7febb92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*******************************************************************************
 * Copyright (c) 2010-2012, Tamas Szabo, Istvan Rath and Daniel Varro
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-v20.html.
 *
 * SPDX-License-Identifier: EPL-2.0
 *******************************************************************************/

package tools.refinery.viatra.runtime.rete.itc.igraph;

import tools.refinery.viatra.runtime.matchers.util.IMemoryView;
import tools.refinery.viatra.runtime.matchers.util.IMultiset;

import java.util.Set;

/**
 * The interface prescribes the set of operations that a graph data source must support.
 * <p> Note that the old version of the interface is broken at version 1.6;
 *  MultiSets are now presented as Maps instead of Lists.
 *
 * @author Tamas Szabo
 *
 * @param <V>
 *            the type of the nodes in the graph
 */
public interface IGraphDataSource<V> {

    /**
     * Attaches a new graph observer to this graph data source. Observers will be notified in the order they have been registered.
     *
     * @param observer the graph observer
     */
    public void attachObserver(IGraphObserver<V> observer);

    /**
     * Attaches a new graph observer to this graph data source as the first one.
     * In the notification order this observer will be the first one as long as another call to this method happens.
     *
     * @param observer the graph observer
     * @since 1.6
     */
    public void attachAsFirstObserver(IGraphObserver<V> observer);

    /**
     * Detaches an already registered graph observer from this graph data source.
     *
     * @param observer the graph observer
     */
    public void detachObserver(IGraphObserver<V> observer);

    /**
     * Returns the complete set of nodes in the graph data source.
     *
     * @return the set of all nodes
     */
    public Set<V> getAllNodes();

    /**
     * Returns the target nodes for the given source node.
     * The returned data structure is an {@link IMultiset} because of potential parallel edges in the graph data source.
     *
     * The method must not return null.
     *
     * @param source the source node
     * @return the multiset of target nodes
     * @since 2.0
     */
    public IMemoryView<V> getTargetNodes(V source);
}