All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.ikm.tinkar.component.graph.Graph Maven / Gradle / Ivy

There is a newer version: 1.78.0
Show newest version
/*
 * Copyright © 2015 Integrated Knowledge Management ([email protected])
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package dev.ikm.tinkar.component.graph;

import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.list.ImmutableList;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.primitive.ImmutableIntList;
import org.eclipse.collections.api.map.primitive.ImmutableIntObjectMap;

import java.util.UUID;

/**
 * TODO: Consider removing and only going with entities...
 * @param 
 */
public interface Graph {

     A adapt(GraphAdaptorFactory adaptorFactory);

    /**
     * @param vertexId a universally unique identifier for a vertex
     * @return the vertex associated with the identifier
     */
    V vertex(UUID vertexId);

    V vertex(int vertexIndex);

    ImmutableList vertexMap();

    ImmutableIntObjectMap successorMap();

    default ImmutableList descendents(V logicVertex) {
        MutableList descendentList = Lists.mutable.empty();
        recursiveAddSuccessors(logicVertex, descendentList);
        return descendentList.toImmutable();
    }

    default void recursiveAddSuccessors(V logicVertex, MutableList descendentList) {
        ImmutableList successorList = successors(logicVertex);
        descendentList.addAllIterable(successorList);
        for (V successor : successorList) {
            recursiveAddSuccessors(successor, descendentList);
        }
    }

    /**
     * @param vertex a vertex to retrieve the successors of
     * @return the successors for the provided vertex
     */
    ImmutableList successors(V vertex);

    ImmutableIntList successors(int vertexIndex);


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy