async def main(): await client.start() print("Client Created") # Ensure you're authorized if not await client.is_user_authorized(): #client.send_code_request(phone) try: client.sign_in(phone, input('Enter the code: ')) except SessionPasswordNeededError: client.sign_in(password=input('Password: '******'dialog found: ', dialog.name) async for message in client.iter_messages(dialog): # print(message.date) add_msg(message) if len(msg_list) == 0: raise Exception('no messages was retrieved') #sort dates_sorted = sort_dates(msg_list[::-1]) #save draw.draw_graph(dates_sorted, dialog_id)
def graph(G, coord, paths, data, color): colors = set_colors(color) graph = set_graph(G, paths, colors) interval = 8 if (data['vertices'] >= 1000) else 500 # set plots fig, ax = plt.subplots(figsize=(23, 13)) options = get_options(G, data['vertices'], ax, coord) ax.set_facecolor(colors['background']) plt.gca().invert_yaxis() #add paths tools tm = fig.canvas.manager.toolmanager tb = fig.canvas.manager.toolbar #create tools tm.add_tool('Shortest', Shortest, graph=graph, options=options) tm.add_tool('Optimum', Optimum, graph=graph, options=options) tm.add_tool('Ants', Ants, fig=fig, interval=interval, graph=graph, options=options) #add tools to navigation bar tb.add_tool('Shortest', 'Navigation') tb.add_tool('Optimum', 'Navigation') tb.add_tool('Ants', 'Navigation') #remove unused tools tm.remove_tool('subplots') #draw base graph draw_graph(0, G, options, None, None, colors) fig.tight_layout() plt.show()
def main(): #generate(1000, 7000) edges, nodes, v = get_data('name.txt') G = nx.Graph() G.add_nodes_from(nodes) G.add_edges_from(edges) label = calculate_all(G, v) draw_graph(G, label)
def process(): print "In this order:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" global canvas_list global res_list global added_flag num_order = int(choose_input.get()) if w == "y": fd.set(status[num_order]) else: fd.set("No weight!") canvas_list = res_list[num_order - 1] draw_graph(canvas_list, w)
#!/usr/bin/env python3 ############################# #@author Karolina Mizera #@author Krystian Molenda #@author Marcin Miś ############################# #import sys #sys.path.append('$(src)') #add path to project_11/src or being all files in the same catalog is required from adjmatrix import AdjMatrix from draw import draw_graph print('''Print matrix on the picture''') fileName = input("Enter adjmatrix file name: ") #enter name of data file. File must be in the same catalog. Examples in catalog /data matrix = AdjMatrix matrix.createAdjMatrixFromFile(matrix,fileName) draw_graph(matrix, 'graph.png')
from adjmatrix import AdjMatrix from adjMatrixFile import SaveToFile from draw import draw_graph print('''Graph generation: GNL - Generate with number of lines GNP - Generate with probability other - exit''') key = input(" ") while (key == 'GNL') or (key == 'GNP'): if key == 'GNL': numberOfTops = int(input("enter number of tops ")) numberOfLines = int(input("enter number of lines ")) gnlAdjMatrix = generateRandomGraph.GNL(numberOfTops, numberOfLines) print(gnlAdjMatrix) SaveToFile(gnlAdjMatrix, "GNL.txt") gnl = AdjMatrix gnl.createAdjMatrixFromFile(gnl, "GNL.txt") draw_graph(gnl, "GNL.png") print(" ") if key == 'GNP': numberOfTops = int(input("enter number of tops ")) probability = float(input("enter probability ")) gnpAdjMatrix = generateRandomGraph.GNP(numberOfTops, probability) print(gnpAdjMatrix) SaveToFile(gnpAdjMatrix, "GNP.txt") gnp = AdjMatrix gnp.createAdjMatrixFromFile(gnp, "GNP.txt") draw_graph(gnp, "GNP.png") print(" ")
def redraw(self): draw_graph(self.fig, self.options, self.dates) self.canvas.draw() self.recomputeLineCommand()
def redraw(self): draw_graph(self.fig, self.options, self.dates) self.canvas.draw() self.recomputeLineCommand()
if (key not in 'AIL') or (fileName != ''): if key == 'A': adjMatrix = AdjMatrix adjMatrix.createAdjMatrixFromFile(adjMatrix, fileName) elif key == 'I': incMatrix = IncidenceMatrix incMatrix.createIncMatrixFromFile(incMatrix, fileName) elif key == 'L': _list = List _list.createListFromFile(_list, fileName) print(" ") #conversions while key in 'AIL': if key == 'A': draw_graph(adjMatrix, 'zad1Graph.png') print('''Convert representation: AI - Adjacency Matrix to Incidence Matrix AL - Adjency Matrix to Adjency List x - exit''') key = input(" ") if key == 'AI': incMatrix = convert.fromAdjMatrixtoIncidenceMatrix(adjMatrix) print(incMatrix.matrix) key = 'I' elif key == 'AL': incMatrix = convert.fromAdjMatrixtoIncidenceMatrix(adjMatrix) _list = incMatrix = convert.fromIncidenceMatrixtoList( incMatrix)
def activity(ui, repo, **opts): # The doc string below will show up in 'hg activity --help' """ Create a file called activity.png displaying the activity of the current repository By default, the activity is computed using the number of commits. There is an option to consider instead the number of lines modified in the changesets (--uselines). Most options are self explanatory. The map file format used to specify aliases is fairly simple: <alias name>; <actual name> This file is only used when --split=authors is used. The name listed after the option --exclude are those found in the mercurial repository. That is, before the map file is applied. """ # do it try: options = check_options(repo, opts) ui.write('There are %d changesets\n' % options.length) # do something with this data: if options.mode=='display': try: import matplotlib.pyplot as plt except: raise UiException('you need matplotlib in your python path in order to use the hg activity extension.') from draw import draw_graph # harvest data dates_tab = collect_data(repo.changelog, options) if len(dates_tab)<1 or not options.length: raise UiException('no data available with those options.') fig = plt.figure() draw_graph(fig, options, dates_tab) plt.show() elif options.mode=='file': try: from matplotlib.figure import Figure from matplotlib.backends.backend_agg import FigureCanvasAgg except: raise UiException('you need matplotlib in your python path in order to use the hg activity extension.') from draw import draw_graph # harvest data dates_tab = collect_data(repo.changelog, options) if len(dates_tab)<1 or not options.length: raise UiException('no data available with those options.') fig = Figure() canvas = FigureCanvasAgg(fig) draw_graph(fig, options, dates_tab) fig.set_dpi(100) fig.set_size_inches(options.width/100.0,options.height/100.0) canvas.print_figure(options.filename) ui.status('Created the file \'%s\'\n' % options.filename) elif options.mode=='gui': from mode_qt import displayQtGui displayQtGui(repo, options) else: raise UiException('unknown mode %s', options.mode) except UiException, error: from sys import exit ui.warn("Hg activity, checking options: %s\n" % error.message) exit(1)
self.index.remove(self.index[0]) imgs.append(img) if self.generate_type == 'train': return imgs, np.nan_to_num(s_labs), np.nan_to_num(s_lab_coms) elif self.generate_type == 'test': return imgs if __name__ == '__main__': from draw import draw_graph generator = generator(input_shape = [368, 368], sample_rate=0.8, score_threshold = 0.1) for i in range(1): imgs, \ labs, \ com_labs = generator.next_(1) imgp = imgs[0].shape #if imgp != (368, 368, 3): # input(imgp) labs[labs<0.3]=0 for i in range(labs.shape[3]): #pass draw_graph(imgs[0], labs[0, :, :, i]).save('test_out_img\\'+str(i)+'.jpg')