def BuildGraphFromSpec(graphData, graph_id, graph_spec, subFolder) : graph_type = graph_spec.pop() questions = graph_spec size = len(graphData) file_name = os.path.join(subFolder, 'SVG', 'graph' + graph_id + '.dot') edges = [] dict = {} for nodeData in graphData: [id, local_id, name, age, edgeGroups] = nodeData dict[id] = local_id # compute all edges for nodeData in graphData: [id, local_id, name, age, edgeGroups] = nodeData for question in questions: targets = edgeGroups[question-1] for target in targets: edges = edges + [[local_id, dict.get(target,'0')]] # compute symmetric edges (pairs of eges) if graph_type == 'pairs' : sym_edges = [] for edge in edges : reverse = [edge[1],edge[0]] if edges.count(reverse) > 0 : sym_edges = sym_edges + [edge] edges = sym_edges # remove duplicates edges = removeDuplicates(edges) # build the graph and the visualization G = SocioGraph.MakeGraphFromEdges(size, edges, graph_type, file_name) # save the graph statistics code = 'val' + BuildTexts.encodeNumber(graph_id) + 'links' if graph_type == 'pairs' : links = len(edges) / 2 else : links = len(edges) BuildTexts.addMacro(subFolder, code, links) # build the rating table if graph_type == 'directed' : BuildRatings.computeRating(subFolder, graph_id, G) return G
def ComputeValues(subFolder, statData) : print '\nCompute the statistics values and build the charts' BuildRatings.buildNamesListFile(subFolder, statData) BuildRatings.addNamesListToHtml(subFolder) BuildRatings.addSizeComments(subFolder, len(statData)) StatValues1.ComputeAll(subFolder, statData) StatValues2.ComputeAll(subFolder, statData) StatValues3.ComputeAll(subFolder, statData) StatValues4.ComputeAll(subFolder, statData) StatValues5.ComputeAll(subFolder, statData)