Skip to content

Commit

Permalink
Updates documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbv committed Feb 11, 2018
1 parent a75b5a3 commit 53e99bd
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 142 deletions.
53 changes: 0 additions & 53 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -619,56 +619,3 @@ Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

pc2graph - A point cloud to NetworkX graph converter.
Copyright (C) 2017 Matheus Boni Vicari

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

pc2graph Copyright (C) 2017 Matheus Boni Vicari
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
2 changes: 2 additions & 0 deletions contributors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Matheus Boni Vicari
([email protected] or [email protected])
34 changes: 11 additions & 23 deletions pc2graph/example.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
# Copyright (c) 2017, Matheus Boni Vicari, TLSeparation Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 3. Neither the name of the Raysect Project nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__author__ = "Matheus Boni Vicari"
__copyright__ = "Copyright 2017, TLSeparation Project"
__copyright__ = "Copyright 2017"
__credits__ = ["Matheus Boni Vicari"]
__license__ = "GPL3"
__version__ = "0.1"
Expand Down
138 changes: 72 additions & 66 deletions pc2graph/shortpath.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
# Copyright (c) 2017, Matheus Boni Vicari, TLSeparation Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 3. Neither the name of the Raysect Project nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__author__ = "Matheus Boni Vicari"
__copyright__ = "Copyright 2017, TLSeparation Project"
__copyright__ = "Copyright 2017"
__credits__ = ["Matheus Boni Vicari"]
__license__ = "GPL3"
__version__ = "0.1"
Expand All @@ -52,24 +40,32 @@ def array_to_graph(arr, base_id, kpairs, knn, nbrs_threshold,
have a common edge.
Args:
arr (array): n-dimensional array of points.
base_id (int): index of base id (root) in the graph.
kpairs (int): number of points around each point in arr to select in
order to build edges.
knn (int): Number of neighbors to search around each point in the
neighborhood phase. The higher the better (careful, it's memory
intensive).
nbrs_threshold (float): Maximum valid distance between neighbors
points.
nbrs_threshold_step (float): Distance increment used in the final
phase of edges generation. It's used to make sure that in the
end, every point in arr will be translated to nodes in the graph.
graph_threshold (float): Maximum distance between pairs of nodes
(edge distance) accepted in the graph generation.
Returns:
G (networkx graph): Graph containing all points in 'arr' as nodes.
Parameters
----------
arr : array
n-dimensional array of points.
base_id :
index of base id (root) in the graph.
kpairs : int
number of points around each point in arr to select in order to build
edges.
knn : int
Number of neighbors to search around each point in the neighborhood
phase. The higher the better (careful, it's memory intensive).
nbrs_threshold : float
Maximum valid distance between neighbors points.
nbrs_threshold_step : float
Distance increment used in the final phase of edges generation. It's
used to make sure that in the end, every point in arr will be
translated to nodes in the graph.
graph_threshold : float
Maximum distance between pairs of nodes (edge distance) accepted in
the graph generation.
Returns
-------
G : networkx graph
Graph containing all points in 'arr' as nodes.
"""

Expand Down Expand Up @@ -204,20 +200,27 @@ def extract_path_info(G, base_id, return_path=True):
"""
Extracts shortest path information from a NetworkX graph.
Args:
G (networkx graph): NetworkX graph object from which to extract
the information.
base_id (int): Base (root) node id to calculate the shortest path for
all other nodes.
return_path (boolean): Option to select if function should output
path list for every node in G to base_id.
Returns:
nodes_ids (list): Indices of all nodes in graph G.
distance (list): Shortest path distance (accumulated) from all
nodes in G to base_id node.
path_list (dict): Dictionary of nodes that comprises the path of
every node in G to base_id node.
Parameters
----------
G : networkx graph
NetworkX graph object from which to extract the information.
base_id : int
Base (root) node id to calculate the shortest path for all other
nodes.
return_path : boolean
Option to select if function should output path list for every node
in G to base_id.
Returns
-------
nodes_ids : list
Indices of all nodes in graph G.
distance : list
Shortest path distance (accumulated) from all nodes in G to base_id
node.
path_list : dict
Dictionary of nodes that comprises the path of every node in G to
base_id node.
"""

Expand Down Expand Up @@ -246,17 +249,20 @@ def add_nodes(G, base_node, indices, distance, threshold):
between base_node and all entries in indices. Each node pair shares an
edge with weight equal to the distance between both nodes.
Args:
G (networkx graph): NetworkX graph object to which all nodes/edges
will be added.
base_node (int): Base node's id to be added. All other nodes will
be paired with base_node to form different edges.
indices (list or array): Set of nodes indices to be paired with
base_node.
distance (list or array): Set of distances between all nodes in
'indices' and base_node.
threshold (float): Edge distance threshold. All edges with distance
larger than 'threshold' will not be added to G.
Parameters
----------
G : networkx graph
NetworkX graph object to which all nodes/edges will be added.
base_node : int
Base node's id to be added. All other nodes will be paired with
base_node to form different edges.
indices : list or array
Set of nodes indices to be paired with base_node.
distance : list or array
Set of distances between all nodes in 'indices' and base_node.
threshold : float
Edge distance threshold. All edges with distance larger than
'threshold' will not be added to G.
"""

Expand Down

0 comments on commit 53e99bd

Please sign in to comment.