Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/patr-schm/surface-maps-via-adaptive-triangulations
30 May 2023, 12:10:02 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    No releases to show
  • 3367d82
  • /
  • src
  • /
  • SurfaceMaps
  • /
  • Utils
  • /
  • Dijkstra.cc
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:aea2e3818c81f7a85b30e619a1d1f2ff0ebfc686
origin badgedirectory badge
swh:1:dir:c2f78cca852cb7cbbf962da63e033e1992b1c0f2
origin badgerevision badge
swh:1:rev:da768497f0b8a84088b7f0d839b8b40a1780c672
origin badgesnapshot badge
swh:1:snp:b226c256e24f85cfb68346d404868c5d0bb72cfd

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: da768497f0b8a84088b7f0d839b8b40a1780c672 authored by Patrick Schmidt on 11 May 2023, 16:25:14 UTC
Add grsi-thumbnail.png
Tip revision: da76849
Dijkstra.cc
/*
 * This file is part of
 * Surface Maps via Adaptive Triangulations
 * (https://github.com/patr-schm/surface-maps-via-adaptive-triangulations)
 * and is released under the MIT license.
 *
 * Authors: Patrick Schmidt, Janis Born
 */

#include "Dijkstra.hh"

#include <SurfaceMaps/Utils/Helpers.hh>
#include <queue>

namespace SurfaceMaps
{

PrimalPath find_primal_path(
        const VH _vh_source,
        const VH _vh_target,
        const TriMesh& _mesh,
        const ExternalProperty<EH, bool>& _blocked_edges,
        ExternalProperty<VH, bool> _blocked_vertices)
{
    PrimalPath path;

    if (_vh_source == _vh_target)
        return path;

    struct DijkstraEdge
    {
        DijkstraEdge(const HEH _heh, const double _distance)
            : heh(_heh), distance(_distance) { }

        // Higher priority if lower distance
        bool operator<(const DijkstraEdge& other) const { return distance > other.distance; }

        HEH heh;
        double distance; // from-vertex to to-vertex
    };

    // Block all vertices incident to blocked edges
    for (auto e : _mesh.edges())
    {
        if (_blocked_edges[e])
        {
            _blocked_vertices[e.v0()] = true;
            _blocked_vertices[e.v1()] = true;
        }
    }

    ExternalProperty<VH, bool> visited(_mesh, false);
    ExternalProperty<VH, HEH> pred(_mesh, HEH(-1)); // heh pointing to vertex
    std::priority_queue<DijkstraEdge> queue;

    auto enqueue = [&] (const HEH heh, const double dist_curr)
    {
        const VH vh_to = _mesh.to_vertex_handle(heh);
        if (visited[vh_to])
            return;

        if (_blocked_vertices[vh_to] && vh_to != _vh_target)
            return;

        const double length = _mesh.calc_edge_length(heh);
        queue.push(DijkstraEdge(heh, dist_curr + length));
    };

    for (const HEH heh : _mesh.voh_range(_vh_source))
        enqueue(heh, 0.0);

    // Dijkstra
    VH vh_curr(-1);
    while (!queue.empty())
    {
        const DijkstraEdge to_curr = queue.top();
        queue.pop();

        // Already found a shorter path?
        vh_curr = _mesh.to_vertex_handle(to_curr.heh);
        if (visited[vh_curr])
            continue;

        visited[vh_curr] = true;
        pred[vh_curr] = to_curr.heh;

        // Reached target?
        if (vh_curr == _vh_target)
            break;

        // Add neighbors
        for (const HEH heh : _mesh.voh_range(vh_curr))
            enqueue(heh, to_curr.distance);
    }

    if (vh_curr != _vh_target)
    {
        ISM_WARNING("Primal Dijkstra did not find target vertex.");
        return path;
    }

    // Trace path from target to source.
    while (vh_curr != _vh_source)
    {
        const HEH heh_pred = pred[vh_curr];
        ISM_ASSERT(_mesh.is_valid_handle(heh_pred));
        path.hehs.push_back(heh_pred);

        vh_curr = _mesh.from_vertex_handle(heh_pred);
    }

    std::reverse(path.hehs.begin(), path.hehs.end());
    return path;
}

}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API