face2face.imports.create_network.event_time_networks¶
-
face2face.imports.create_network.
event_time_networks
(Data, events)¶ Create multiple Networkx Graphs and DataFrames
Creating multiple Networkx Graphs and DataFrames based on a given event list.
- Parameters
Data (Data) – Data Object that contains Tij- and Metadata for a data set.
events (list) – A list of tuples that contains the eventname and the start and the beginning of the event.
- Returns
network_list (list) – A list of all networkx Graphs for a given interval.
df_list (list) – A list of all dataframes for a given interval.
Examples
>>> attr_list = ["ID", "Age", "Sex"] >>> test_df = Data(path_tij="face2face/data/Test/tij_test.dat", separator_tij="\t", >>> path_meta="face2face/data/Test/meta_test.dat", separator_meta = "\t", >>> meta_attr_list=attr_list)
>>> event_list = [("Event A", 20, 60), ("Event B", 120, 180), ("Event C", 400, 500)]
>>> test_network_list, test_df_list = event_time_networks(test_df, events=event_list) >>> print(test_df_list[0]) Time i j TimeGroup 1 40 1 2 Event A 2 40 1 3 Event A 3 40 2 3 Event A 4 60 4 6 Event A 5 60 4 7 Event A 6 60 6 7 Event A >>> print(test_network_list[0].nodes) [1, 2, 3, 4, 6, 7] >>> print(test_network_list[0].edges) [(1, 2), (1, 3), (2, 3), (4, 6), (4, 7), (6, 7)] >>> print(test_df_list[1]) Time i j TimeGroup 13 140 7 6 Event B 14 140 4 6 Event B 15 140 7 4 Event B 16 160 7 6 Event B 17 160 4 6 Event B 18 160 7 4 Event B 19 180 7 6 Event B 20 180 4 6 Event B 21 180 7 4 Event B >>> print(test_network_list[1].nodes) [4, 6, 7] >>> print(test_network_list[1].edges) [(4, 6), (4, 7), (6, 7)] >>> print(test_df_list[2]) Time i j TimeGroup 25 420 4 6 Event C 26 420 4 7 Event C 27 420 6 7 Event C 28 440 4 6 Event C 29 440 4 7 Event C 30 440 6 7 Event C 31 440 1 2 Event C 32 440 1 3 Event C 33 440 2 3 Event C 34 460 1 2 Event C 35 460 1 3 Event C 36 460 2 3 Event C 37 460 10 11 Event C 38 460 11 12 Event C 39 460 10 12 Event C 40 500 10 11 Event C 41 500 11 12 Event C 42 500 10 12 Event C >>> print(test_network_list[2].nodes) [1, 2, 3, 4, 6, 7, 10, 11, 12] >>> print(test_network_list[2].edges) [(1, 2), (1, 3), (2, 3), (4, 6), (4, 7), (6, 7), (10, 11), (10, 12), (11, 12)]