@@ -756,6 +756,8 @@ C_INTERFACE CalculateAndStoreEnergyExpenditure(HF::SpatialStructures::Graph* g);
756
756
\see \ref graph_setup (how to create a graph)
757
757
\see \ref graph_add_edge_from_nodes (how to add edges to a graph using nodes)
758
758
\see \ref graph_add_edge_from_node_ids (how to add edges to a graph using node IDs)
759
+ \see \link GetNodeAttributes \endlink (how to get string node attributes)
760
+ \see \link GetNodeAttributesByID \endlink (how to get string node attributes by node ID)
759
761
\see \ref graph_compress (how to compress a graph after adding/removing edges)
760
762
\see \ref graph_get_csr_pointers (how to retrieve a CSR representation of a graph)
761
763
\see \ref graph_teardown (how to destroy a graph)
@@ -780,6 +782,56 @@ C_INTERFACE AddNodeAttributes(
780
782
int num_nodes
781
783
);
782
784
785
+ /* !
786
+ \brief Add a new float node attribute in the graph for the nodes at ids.
787
+
788
+ \param g Graph to add attributes to
789
+ \param ids IDs of nodes to add attributes to
790
+ \param attribute The name of the attribute to add the scores to.
791
+
792
+ \param scores An ordered array of floats
793
+ that correspond to the score of the ID in ids at the same index.
794
+
795
+ \param num_nodes Length of both the ids and scores arrays
796
+
797
+ \returns \link HF_STATUS::OK \endlink on completion.
798
+ Note that this does not guarantee that some
799
+ or all of the node attributes have been added
800
+
801
+ \details
802
+ For any id in ids, if said ID doesn't already exist in the graph, then it and its cost will
803
+ silently be ignored without error.
804
+
805
+ \pre ids and scores arrays must be the same length
806
+
807
+ \see \ref graph_setup (how to create a graph)
808
+ \see \ref graph_add_edge_from_nodes (how to add edges to a graph using nodes)
809
+ \see \ref graph_add_edge_from_node_ids (how to add edges to a graph using node IDs)
810
+ \see \link GetNodeAttributesFloat \endlink (how to get float node attributes)
811
+ \see \link GetNodeAttributesByIDFloat \endlink (how to get float node attributes by node ID)
812
+ \see \ref graph_compress (how to compress a graph after adding/removing edges)
813
+ \see \ref graph_get_csr_pointers (how to retrieve a CSR representation of a graph)
814
+ \see \ref graph_teardown (how to destroy a graph)
815
+
816
+ Begin by reviewing the example at \ref graph_setup to create a graph.<br>
817
+
818
+ You may add edges to the graph using nodes (\ref graph_add_edge_from_nodes)<br>
819
+ or alternative, you may provide node IDs (\ref graph_add_edge_from_node_IDs).<br>
820
+
821
+ Be sure to compress the graph (\ref graph_compress) every time you add/remove edges.<br>
822
+
823
+ \snippet tests\src\spatialstructures_C_cinterface.cpp snippet_spatialstructuresC_AddNodeAttributesFloat
824
+
825
+ Finally, when you are finished with the graph,<br>
826
+ it must be destroyed. (\ref graph_teardown)
827
+ */
828
+ C_INTERFACE AddNodeAttributesFloat (
829
+ HF::SpatialStructures::Graph* g,
830
+ const int * ids,
831
+ const char * attribute,
832
+ const float * scores,
833
+ int num_nodes
834
+ );
783
835
/* !
784
836
\brief Retrieve node attribute values from *g
785
837
@@ -791,6 +843,8 @@ C_INTERFACE AddNodeAttributes(
791
843
\param out_score_size Keeps track of the size of out_scores buffer,
792
844
updated as required
793
845
846
+ \pre `attribute` is a string attribute. That is, at least one string value has been added to this attribute.
847
+
794
848
\returns \link HF_STATUS::OK \endlink on completion.
795
849
796
850
\details Memory shall be allocated in *out_scores to hold the char arrays.
@@ -802,8 +856,8 @@ C_INTERFACE AddNodeAttributes(
802
856
\see \ref graph_setup (how to create a graph)
803
857
\see \ref graph_compress (how to compress a graph after adding/removing edges)
804
858
\see \ref graph_get_csr_pointers (how to retrieve a CSR representation of a graph)
805
- \see \link AddNodeAttributes \endlink (how to add node attributes)
806
- \see \link GetNodeAttributesByID \endlink (how to get node attributes by node ID)
859
+ \see \link AddNodeAttributes \endlink (how to add string node attributes)
860
+ \see \link GetNodeAttributesByID \endlink (how to get string node attributes by node ID)
807
861
\see \ref graph_teardown (how to destroy a graph)
808
862
809
863
Begin by reviewing the example at \ref graph_setup to create a graph.<br>
@@ -835,6 +889,7 @@ C_INTERFACE GetNodeAttributes(
835
889
836
890
\pre All node IDs in `ids` must exist in graph `g`.
837
891
\pre If `ids` is not NULL, `num_nodes` must be equal to the length of `ids`.
892
+ \pre `attribute` is a string attribute. That is, at least one string value has been added to this attribute.
838
893
\returns \link HF_STATUS::OK \endlink on completion.
839
894
840
895
\details For the ID at `ids[i]`, `out_scores[i]` is the value of the attribute for the
@@ -852,8 +907,8 @@ C_INTERFACE GetNodeAttributes(
852
907
\see \ref graph_setup (how to create a graph)
853
908
\see \ref graph_compress (how to compress a graph after adding/removing edges)
854
909
\see \ref graph_get_csr_pointers (how to retrieve a CSR representation of a graph)
855
- \see \link AddNodeAttributes \endlink (how to add node attributes)
856
- \see \link GetNodeAttributes \endlink (how to get node attributes)
910
+ \see \link AddNodeAttributes \endlink (how to add string node attributes)
911
+ \see \link GetNodeAttributes \endlink (how to get string node attributes)
857
912
\see \ref graph_teardown (how to destroy a graph)
858
913
859
914
Begin by reviewing the example at \ref graph_setup to create a graph.<br>
@@ -871,6 +926,106 @@ C_INTERFACE GetNodeAttributesByID(
871
926
char ** out_scores,
872
927
int * out_score_size
873
928
);
929
+ /* !
930
+ \brief Retrieve float node attribute values from *g
931
+
932
+ \param g The graph that will be used to retrieve
933
+ node attribute values from
934
+
935
+ \param attribute The node attribute type to retrieve from *g
936
+ \param out_scores Pointer to array of float, allocated by the caller
937
+ \param out_score_size Keeps track of the size of out_scores buffer,
938
+ updated as required
939
+
940
+ \pre `attribute` is a float attribute. That is, only float values have been added to this attribute.
941
+
942
+ \returns \link HF_STATUS::OK \endlink on completion.
943
+
944
+ \details The caller must deallocate the memory addressed by out_scores.
945
+
946
+ \see \ref graph_setup (how to create a graph)
947
+ \see \ref graph_compress (how to compress a graph after adding/removing edges)
948
+ \see \ref graph_get_csr_pointers (how to retrieve a CSR representation of a graph)
949
+ \see \link AddNodeAttributesFloat \endlink (how to add float node attributes)
950
+ \see \link GetNodeAttributesByIDFloat \endlink (how to get float node attributes by node ID)
951
+ \see \ref graph_teardown (how to destroy a graph)
952
+
953
+ Begin by reviewing the example at \ref graph_setup to create a graph.<br>
954
+
955
+ \snippet tests\src\spatialstructures_C_cinterface.cpp snippet_spatialstructuresC_GetNodeAttributesFloat
956
+
957
+ Finally, when you are finished with the graph,<br>
958
+ it must be destroyed. (\ref graph_teardown)
959
+ */
960
+ C_INTERFACE GetNodeAttributesFloat (
961
+ const HF::SpatialStructures::Graph* g,
962
+ const char * attribute,
963
+ float * out_scores,
964
+ int * out_score_size
965
+ );
966
+
967
+ /* !
968
+ \brief Retrieve float node attribute values from *g
969
+
970
+ \param g The graph that will be used to retrieve
971
+ node attribute values from
972
+ \param ids The list of node IDs to get attributes for.
973
+ If NULL, returns attributes for all nodes.
974
+ \param attribute The node attribute type to retrieve from *g
975
+ \param num_nodes The length of the ids array
976
+ \param out_scores Pointer to array of floats, allocated by the caller
977
+ \param out_score_size Keeps track of the size of out_scores buffer,
978
+ updated as required
979
+
980
+ \pre All node IDs in `ids` must exist in graph `g`.
981
+ \pre If `ids` is not NULL, `num_nodes` must be equal to the length of `ids`.
982
+ \pre `attribute` is a float attribute. That is, only float values have been added to this attribute.
983
+
984
+ \returns \link HF_STATUS::OK \endlink on completion.
985
+
986
+ \details For the ID at `ids[i]`, `out_scores[i]` is the value of the attribute for the
987
+ node associated with that ID.
988
+
989
+ If `ids` is NULL, `out_scores` is an array holding the value of the attribute for
990
+ all nodes, sorted in ascending order by ID.
991
+
992
+ The caller must deallocate the memory addressed by out_scores.
993
+
994
+ \see \ref graph_setup (how to create a graph)
995
+ \see \ref graph_compress (how to compress a graph after adding/removing edges)
996
+ \see \ref graph_get_csr_pointers (how to retrieve a CSR representation of a graph)
997
+ \see \link AddNodeAttributesFloat \endlink (how to add float node attributes)
998
+ \see \link GetNodeAttributesFloat \endlink (how to get float node attributes)
999
+ \see \ref graph_teardown (how to destroy a graph)
1000
+
1001
+ Begin by reviewing the example at \ref graph_setup to create a graph.<br>
1002
+
1003
+ \snippet tests\src\spatialstructures_C_cinterface.cpp snippet_spatialstructuresC_GetNodeAttributesByIDFloat
1004
+
1005
+ Finally, when you are finished with the graph,<br>
1006
+ it must be destroyed. (\ref graph_teardown)
1007
+ */
1008
+ C_INTERFACE GetNodeAttributesByIDFloat (
1009
+ const HF::SpatialStructures::Graph* g,
1010
+ const int * ids,
1011
+ const char * attribute,
1012
+ int num_nodes,
1013
+ float * out_scores,
1014
+ int * out_score_size
1015
+ );
1016
+
1017
+ /* !
1018
+ \brief Check whether or not an attribute is stored with float values in a graph.
1019
+ \param g The pointer of the graph to check
1020
+ \param attribute The attribute to check
1021
+
1022
+ \returns 1 if the attribute exists in the graph and contains only float values.
1023
+ 0 otherwise.
1024
+ */
1025
+ C_INTERFACE IsFloatAttribute (
1026
+ const HF::SpatialStructures::Graph* g,
1027
+ const char * attribute
1028
+ );
874
1029
875
1030
/* !
876
1031
\brief Free the memory of every (char *) in scores_to_delete.
0 commit comments