raphtory 0.17.0

raphtory, a temporal graph library
Documentation
//ALGORITHMS

#[cfg(feature = "storage")]
use crate::python::graph::disk_graph::PyDiskGraph;
use crate::{
    add_classes, add_functions,
    python::{
        algorithm::{epidemics::PyInfected, max_weight_matching::PyMatching},
        graph::{
            edge::{PyEdge, PyMutableEdge},
            edges::{PyEdges, PyNestedEdges},
            graph::{PyGraph, PyGraphEncoder},
            graph_with_deletions::PyPersistentGraph,
            history::{
                HistoryDateTimeIterable, HistoryEventIdIterable, HistoryIterable,
                HistoryTimestampIterable, IntervalsIterable, NestedHistoryDateTimeIterable,
                NestedHistoryEventIdIterable, NestedHistoryIterable,
                NestedHistoryTimestampIterable, NestedIntervalsIterable, PyHistory,
                PyHistoryDateTime, PyHistoryEventId, PyHistoryTimestamp, PyIntervals,
            },
            index::{PyIndexSpec, PyIndexSpecBuilder},
            node::{PyMutableNode, PyNode, PyNodes, PyPathFromGraph, PyPathFromNode},
            properties::{
                MetadataView, PropertiesView, PyMetadata, PyPropValueList, PyProperties,
                PyTemporalProp, PyTemporalProperties,
            },
            views::graph_view::PyGraphView,
        },
        packages::{
            algorithms::*,
            graph_gen::*,
            graph_loader::*,
            vectors::{
                embedding_server, PyOpenAIEmbeddings, PyVectorCache, PyVectorSelection,
                PyVectorisedGraph,
            },
        },
        types::{
            result_iterable::{
                NestedResultOptionUtcDateTimeIterable, NestedResultUtcDateTimeIterable,
                ResultOptionUtcDateTimeIterable, ResultUtcDateTimeIterable,
            },
            wrappers::{
                document::{PyDocument, PyEmbedding},
                iterables::{
                    ArcStringIterable, ArcStringVecIterable, BoolIterable, EventTimeIterable,
                    GIDGIDIterable, GIDIterable, I64Iterable, NestedArcStringIterable,
                    NestedArcStringVecIterable, NestedBoolIterable, NestedEventTimeIterable,
                    NestedGIDGIDIterable, NestedGIDIterable, NestedI64Iterable,
                    NestedI64VecIterable, NestedOptionArcStringIterable,
                    NestedOptionEventTimeIterable, NestedOptionI64Iterable,
                    NestedOptionUsizeIterable, NestedStringIterable, NestedUsizeIterable,
                    NestedUtcDateTimeIterable, NestedVecUtcDateTimeIterable,
                    OptionArcStringIterable, OptionEventTimeIterable, OptionI64Iterable,
                    OptionUsizeIterable, OptionUtcDateTimeIterable, OptionVecUtcDateTimeIterable,
                    StringIterable, U64Iterable, UsizeIterable,
                },
            },
        },
        utils::PyWindowSet,
    },
};
use pyo3::prelude::*;
use raphtory_api::python::{
    prop::PyPropType,
    timeindex::{PyEventTime, PyOptionalEventTime},
    PyProp,
};

pub fn add_raphtory_classes(m: &Bound<PyModule>) -> PyResult<()> {
    //Graph classes
    add_classes!(
        m,
        PyGraphView,
        PyGraph,
        PyPersistentGraph,
        PyGraphEncoder,
        PyNode,
        PyNodes,
        PyPathFromNode,
        PyPathFromGraph,
        PyMutableNode,
        PyEdge,
        PyEdges,
        PyNestedEdges,
        PyMutableEdge,
        PyProperties,
        PyPropValueList,
        PyPropType,
        PyMetadata,
        MetadataView,
        PyTemporalProperties,
        PropertiesView,
        PyTemporalProp,
        PyEventTime,
        PyOptionalEventTime,
        PyHistory,
        PyHistoryTimestamp,
        PyHistoryDateTime,
        PyHistoryEventId,
        PyIntervals,
        PyWindowSet,
        PyIndexSpecBuilder,
        PyIndexSpec,
        PyProp
    );

    #[pyfunction]
    /// Return Raphtory version.
    ///
    /// Returns:
    ///     str:
    pub(crate) fn version() -> String {
        String::from(crate::version())
    }

    m.add_function(wrap_pyfunction!(version, m)?)?;

    #[cfg(feature = "storage")]
    add_classes!(m, PyDiskGraph);
    Ok(())
}

pub fn base_iterables_module(py: Python<'_>) -> Result<Bound<'_, PyModule>, PyErr> {
    let iterables_module = PyModule::new(py, "iterables")?;
    add_classes!(
        iterables_module,
        NestedUtcDateTimeIterable,
        NestedGIDIterable,
        GIDIterable,
        StringIterable,
        OptionArcStringIterable,
        UsizeIterable,
        OptionI64Iterable,
        NestedOptionArcStringIterable,
        NestedStringIterable,
        NestedOptionI64Iterable,
        NestedI64VecIterable,
        NestedUsizeIterable,
        BoolIterable,
        ArcStringIterable,
        NestedVecUtcDateTimeIterable,
        OptionVecUtcDateTimeIterable,
        GIDGIDIterable,
        NestedGIDGIDIterable,
        NestedBoolIterable,
        U64Iterable,
        OptionUtcDateTimeIterable,
        ArcStringVecIterable,
        NestedArcStringVecIterable,
        NestedEventTimeIterable,
        NestedArcStringIterable,
        NestedOptionEventTimeIterable,
        NestedHistoryIterable,
        EventTimeIterable,
        OptionEventTimeIterable,
        HistoryIterable,
        HistoryTimestampIterable,
        IntervalsIterable,
        HistoryEventIdIterable,
        HistoryDateTimeIterable,
        OptionUsizeIterable,
        ResultOptionUtcDateTimeIterable,
        I64Iterable,
        ResultUtcDateTimeIterable,
        NestedHistoryTimestampIterable,
        NestedIntervalsIterable,
        NestedHistoryEventIdIterable,
        NestedHistoryDateTimeIterable,
        NestedOptionUsizeIterable,
        NestedResultOptionUtcDateTimeIterable,
        NestedI64Iterable,
        NestedResultUtcDateTimeIterable,
        MetadataListList,
        PyNestedPropsIterable,
    );
    Ok(iterables_module)
}

pub fn base_algorithm_module(py: Python<'_>) -> Result<Bound<'_, PyModule>, PyErr> {
    let algorithm_module = PyModule::new(py, "algorithms")?;
    add_functions!(
        &algorithm_module,
        dijkstra_single_source_shortest_paths,
        global_reciprocity,
        betweenness_centrality,
        all_local_reciprocity,
        triplet_count,
        local_triangle_count,
        average_degree,
        directed_graph_density,
        degree_centrality,
        alternating_mask,
        max_degree,
        min_degree,
        max_out_degree,
        max_in_degree,
        min_out_degree,
        min_in_degree,
        pagerank,
        single_source_shortest_path,
        global_clustering_coefficient,
        temporally_reachable_nodes,
        temporal_bipartite_graph_projection,
        local_clustering_coefficient,
        local_clustering_coefficient_batch,
        weakly_connected_components,
        strongly_connected_components,
        in_components,
        in_component,
        out_components,
        out_component,
        fast_rp,
        global_temporal_three_node_motif,
        global_temporal_three_node_motif_multi,
        local_temporal_three_node_motifs,
        hits,
        balance,
        label_propagation,
        k_core,
        temporal_SEIR,
        louvain,
        fruchterman_reingold,
        cohesive_fruchterman_reingold,
        max_weight_matching
    );

    add_classes!(&algorithm_module, PyMatching, PyInfected);
    #[cfg(feature = "storage")]
    add_functions!(&algorithm_module, connected_components);
    Ok(algorithm_module)
}

pub fn base_graph_loader_module(py: Python<'_>) -> Result<Bound<'_, PyModule>, PyErr> {
    let graph_loader_module = PyModule::new(py, "graph_loader")?;
    add_functions!(
        &graph_loader_module,
        lotr_graph,
        lotr_graph_with_props,
        neo4j_movie_graph,
        stable_coin_graph,
        reddit_hyperlink_graph,
        reddit_hyperlink_graph_local,
        karate_club_graph,
    );
    Ok(graph_loader_module)
}

pub fn base_graph_gen_module(py: Python<'_>) -> Result<Bound<'_, PyModule>, PyErr> {
    let graph_gen_module = PyModule::new(py, "graph_gen")?;
    add_functions!(
        &graph_gen_module,
        random_attachment,
        ba_preferential_attachment,
    );
    Ok(graph_gen_module)
}

pub fn base_vectors_module(py: Python<'_>) -> Result<Bound<'_, PyModule>, PyErr> {
    let vectors_module = PyModule::new(py, "vectors")?;
    add_classes!(
        &vectors_module,
        PyVectorisedGraph,
        PyDocument,
        PyEmbedding,
        PyVectorSelection,
        PyOpenAIEmbeddings,
        PyVectorCache,
    );
    add_functions!(&vectors_module, embedding_server);
    Ok(vectors_module)
}

pub use crate::python::graph::node_state::base_node_state_module;
use crate::python::graph::properties::{MetadataListList, PyNestedPropsIterable};