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

com.targomo.client.api.pojo.BaseGraph Maven / Gradle / Ivy

There is a newer version: 0.39.0
Show newest version
package com.targomo.client.api.pojo;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;

import java.io.Serializable;

/**
 * The basegraph is a POJO representation of an unweighted directed graph, it consists nodes and directed edges between them.
 */
public class BaseGraph implements Serializable {

    private static final BaseGraph emptyImmutableBaseGraph = new BaseGraph(0L);

    public static BaseGraph getEmptyImmutableBaseGraph() {
        return emptyImmutableBaseGraph;
    }

    private final long networkID;
    protected final TIntObjectMap nodes;
    protected final TIntObjectMap edges;
    protected final TIntObjectMap supportingPoints;

    public BaseGraph(long networkID) {
        this.networkID = networkID;
        this.nodes = new TIntObjectHashMap<>();
        this.edges = new TIntObjectHashMap<>();
        this.supportingPoints = new TIntObjectHashMap<>();
    }

    public BaseGraph(BaseGraph source) {
        this(source.getNetworkID(),
                new TIntObjectHashMap<>(source.getNodes()),
                new TIntObjectHashMap<>(source.getEdges()),
                new TIntObjectHashMap<>(source.getSupportingPoints()));
    }

    @JsonCreator
    public BaseGraph(@JsonProperty("networkID") long networkID,
                     @JsonProperty("nodes") TIntObjectMap nodes,
                     @JsonProperty("edges") TIntObjectMap edges,
                     @JsonProperty("supportingPoints") TIntObjectMap supportingPoints) {
        this.networkID = networkID;
        this.nodes = nodes;
        this.edges = edges;
        this.supportingPoints = supportingPoints;
    }

    public long getNetworkID() {
        return networkID;
    }

    public TIntObjectMap getNodes() {
        return nodes;
    }

    public TIntObjectMap getEdges() {
        return edges;
    }

    public TIntObjectMap getSupportingPoints() {
        return supportingPoints;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy