|
| 1 | +from ctypes import c_char_p, c_int, c_void_p, CFUNCTYPE, POINTER, Structure |
| 2 | + |
| 3 | +from .types import ( |
| 4 | + igraph_bool_t, |
| 5 | + igraph_error_t, |
| 6 | + igraph_es_t, |
| 7 | + igraph_integer_t, |
| 8 | + igraph_strvector_t, |
| 9 | + igraph_t, |
| 10 | + igraph_vector_bool_t, |
| 11 | + igraph_vector_int_t, |
| 12 | + igraph_vector_int_list_t, |
| 13 | + igraph_vector_ptr_t, |
| 14 | + igraph_vector_t, |
| 15 | + igraph_vs_t, |
| 16 | +) |
| 17 | + |
| 18 | + |
| 19 | +p_igraph_t = POINTER(igraph_t) |
| 20 | +p_strvector_t = POINTER(igraph_strvector_t) |
| 21 | +p_vector_t = POINTER(igraph_vector_t) |
| 22 | +p_vector_bool_t = POINTER(igraph_vector_bool_t) |
| 23 | +p_vector_int_t = POINTER(igraph_vector_int_t) |
| 24 | +p_vector_int_list_t = POINTER(igraph_vector_int_list_t) |
| 25 | +p_vector_ptr_t = POINTER(igraph_vector_ptr_t) |
| 26 | + |
| 27 | + |
| 28 | +class igraph_attribute_combination_t(Structure): |
| 29 | + """ctypes representation of ``igraph_attribute_combination_t``""" |
| 30 | + |
| 31 | + _fields_ = [("list", igraph_vector_ptr_t)] |
| 32 | + |
| 33 | + |
| 34 | +class igraph_attribute_combination_record_t(Structure): |
| 35 | + """ctypes representation of ``igraph_attribute_combination_record_t``""" |
| 36 | + |
| 37 | + _fields_ = [("name", c_char_p), ("type", c_int), ("func", CFUNCTYPE(c_void_p))] |
| 38 | + |
| 39 | + |
| 40 | +p_attribute_combination_t = POINTER(igraph_attribute_combination_t) |
| 41 | + |
| 42 | + |
| 43 | +class igraph_attribute_table_t(Structure): |
| 44 | + """ctypes representation of ``igraph_attribute_table_t``""" |
| 45 | + |
| 46 | + TYPES = { |
| 47 | + "init": CFUNCTYPE(igraph_error_t, p_igraph_t, p_vector_ptr_t), |
| 48 | + "destroy": CFUNCTYPE(None, p_igraph_t), |
| 49 | + "copy": CFUNCTYPE( |
| 50 | + igraph_error_t, |
| 51 | + p_igraph_t, |
| 52 | + p_igraph_t, |
| 53 | + igraph_bool_t, |
| 54 | + igraph_bool_t, |
| 55 | + igraph_bool_t, |
| 56 | + ), |
| 57 | + "add_vertices": CFUNCTYPE( |
| 58 | + igraph_error_t, p_igraph_t, igraph_integer_t, p_vector_ptr_t |
| 59 | + ), |
| 60 | + "permute_vertices": CFUNCTYPE( |
| 61 | + igraph_error_t, p_igraph_t, p_igraph_t, p_vector_int_t |
| 62 | + ), |
| 63 | + "combine_vertices": CFUNCTYPE( |
| 64 | + igraph_error_t, |
| 65 | + p_igraph_t, |
| 66 | + p_igraph_t, |
| 67 | + p_vector_int_list_t, |
| 68 | + p_attribute_combination_t, |
| 69 | + ), |
| 70 | + "add_edges": CFUNCTYPE( |
| 71 | + igraph_error_t, p_igraph_t, p_vector_int_t, p_vector_ptr_t |
| 72 | + ), |
| 73 | + "permute_edges": CFUNCTYPE( |
| 74 | + igraph_error_t, p_igraph_t, p_igraph_t, p_vector_int_t |
| 75 | + ), |
| 76 | + "combine_edges": CFUNCTYPE( |
| 77 | + igraph_error_t, |
| 78 | + p_igraph_t, |
| 79 | + p_igraph_t, |
| 80 | + p_vector_int_list_t, |
| 81 | + p_attribute_combination_t, |
| 82 | + ), |
| 83 | + "get_info": CFUNCTYPE( |
| 84 | + igraph_error_t, |
| 85 | + p_igraph_t, |
| 86 | + p_strvector_t, |
| 87 | + p_vector_int_t, |
| 88 | + p_strvector_t, |
| 89 | + p_vector_int_t, |
| 90 | + p_strvector_t, |
| 91 | + p_vector_int_t, |
| 92 | + ), |
| 93 | + "has_attr": CFUNCTYPE(igraph_bool_t, p_igraph_t, c_int, c_char_p), |
| 94 | + "get_type": CFUNCTYPE( |
| 95 | + igraph_error_t, p_igraph_t, POINTER(c_int), c_int, c_char_p |
| 96 | + ), |
| 97 | + "get_numeric_graph_attr": CFUNCTYPE(p_igraph_t, c_char_p, p_vector_t), |
| 98 | + "get_string_graph_attr": CFUNCTYPE(p_igraph_t, c_char_p, p_strvector_t), |
| 99 | + "get_bool_graph_attr": CFUNCTYPE(p_igraph_t, c_char_p, p_vector_bool_t), |
| 100 | + "get_numeric_vertex_attr": CFUNCTYPE( |
| 101 | + p_igraph_t, c_char_p, igraph_vs_t, p_vector_t |
| 102 | + ), |
| 103 | + "get_string_vertex_attr": CFUNCTYPE( |
| 104 | + p_igraph_t, c_char_p, igraph_vs_t, p_strvector_t |
| 105 | + ), |
| 106 | + "get_bool_vertex_attr": CFUNCTYPE( |
| 107 | + p_igraph_t, c_char_p, igraph_vs_t, p_vector_bool_t |
| 108 | + ), |
| 109 | + "get_numeric_edge_attr": CFUNCTYPE( |
| 110 | + p_igraph_t, c_char_p, igraph_es_t, p_vector_t |
| 111 | + ), |
| 112 | + "get_string_edge_attr": CFUNCTYPE( |
| 113 | + p_igraph_t, c_char_p, igraph_es_t, p_strvector_t |
| 114 | + ), |
| 115 | + "get_bool_edge_attr": CFUNCTYPE( |
| 116 | + p_igraph_t, c_char_p, igraph_es_t, p_vector_bool_t |
| 117 | + ), |
| 118 | + } |
| 119 | + |
| 120 | + _fields_ = [ |
| 121 | + ("init", TYPES["init"]), |
| 122 | + ("destroy", TYPES["destroy"]), |
| 123 | + ("copy", TYPES["copy"]), |
| 124 | + ("add_vertices", TYPES["add_vertices"]), |
| 125 | + ("permute_vertices", TYPES["permute_vertices"]), |
| 126 | + ("combine_vertices", TYPES["combine_vertices"]), |
| 127 | + ("add_edges", TYPES["add_edges"]), |
| 128 | + ("permute_edges", TYPES["permute_edges"]), |
| 129 | + ("combine_edges", TYPES["combine_edges"]), |
| 130 | + ("get_info", TYPES["get_info"]), |
| 131 | + ("has_attr", TYPES["has_attr"]), |
| 132 | + ("get_numeric_graph_attr", TYPES["get_numeric_graph_attr"]), |
| 133 | + ("get_string_graph_attr", TYPES["get_string_graph_attr"]), |
| 134 | + ("get_bool_graph_attr", TYPES["get_bool_graph_attr"]), |
| 135 | + ("get_numeric_vertex_attr", TYPES["get_numeric_vertex_attr"]), |
| 136 | + ("get_string_vertex_attr", TYPES["get_string_vertex_attr"]), |
| 137 | + ("get_bool_vertex_attr", TYPES["get_bool_vertex_attr"]), |
| 138 | + ("get_numeric_edge_attr", TYPES["get_numeric_edge_attr"]), |
| 139 | + ("get_string_edge_attr", TYPES["get_string_edge_attr"]), |
| 140 | + ("get_bool_edge_attr", TYPES["get_bool_edge_attr"]), |
| 141 | + ] |
0 commit comments