Python & NetworkX for Network Topology Data
I tried thousands of times to apply "NetworkX" Python library to analyze the datasets found by this link:
http://konect.unikoblenz.de/networks/topology
As long as I execute my Python code to the data found there I got, for example, some unrealistic results.
g = nx.read_weighted_edgelist('out.topology')
g.size()
0
0 as a result for this huge data is completely wrong !
Could you please help me to read this data through "NetworkX" Python library ?
1 answer

As someone mentioned trying reading the list gets errors. However, if you get rid of the first line (
% sym positive
) and try the code below to create your graph it should be fine:import networkx as nx with open("out.topology", 'rt') as f: g = nx.parse_edgelist(f, create_using=nx.DiGraph(), data=[('weight', float), ('timestamp', float)])
The data contains 4 columns: source  target  weight  timestamp of edge.
Just include that info in the arguments as shown in my snippet.
See also questions close to this topic

django F ceil divison
I'm making annotate expression, and I don't know how to realize what I expect. The model has 3 integer fields "AA","BB","CC" and my goal is to calculate those 3 like
int(math.ceil(float(AA) / (BB)) *CC)
If AA=4,BB=2,CC=3, then the answer is 6. *case1
And AA=5,BB=2,CC=3, it takes 9. *case2
annotate(ans=F("AA")/F("BB")*("CC"))
This is enough for case1 because AA/BB is not rounded off,
but in case2, the answer takes 6.
I looked up this solution and found some ways. But I couldn't make it...

How do I make a multiplayer concurrent game in Django?
Noob here. I'm trying to create a multiplayer game, in each team there would be 3 people. Person B submits after Person A and Person C after Person B. How do I achieve this? Preferably in python (Django).

Differ between integer and float in an array
I have an assignment where I'm handed an array with numbers, integers, floats and possibly strings. I then have to identify which of the elements are contained in another array with pure integers and which are not. Those which are not contained in the array with integers must be printed and the user must change the element to a value that is contained in the array with integers. Though I have the problem that if the element in the element in the given array is a float, the output from the user's input also becomes a float, (Unless the input is a value from the array with integers.) The same problem also occurs if the element in the given array is an integer and the user's input is a float. Then the float rounds down to an integer. Can anyone give any tips how I should change this code, so the script runs flawless?
grades = np.array([3,10.5,0,7,4,8,4,7,10,5]) SevenGradeScale = np.array([3, 0, 2, 4, 7, 10, 12]) SevenGradeScale = SevenGradeScale.astype(int) for i in range(np.size(grades)): if grades[i] not in SevenGradeScale: while True: if grades[i] in SevenGradeScale: grades = grades.astype(int) print("The grade has been changed to {:d}. ".format(grades[i])) break elif type(grades[i]) is np.float64: print("\n{:.1f} is not a valid grade. The grade must be an integer.".format(grades[i])) elif type(grades[i]) is np.int32: print("\n{:d} is not within the seven grade scale.".format(grades[i])) elif type(grades[i]) is str: type("\n{:s} is not a valid grade.".format(grades[i])) try: grades[i] = float(input("Insert new grade: ")) except ValueError: pass
You would probably comment the "float(input())" but this somehow helped my script. Though I don't know if there are other possibilities.
When running the code and typing random inputs, I get following results
 10.5 is not a valid grade. The grade must be an integer. Insert new grade: 10.7 10.7 is not a valid grade. The grade must be an integer. Insert new grade: 10 The grade has been changed to 10. 8 is not within the seven grade scale. Insert new grade: 7.5 The grade has been changed to 7. 5 is not within the seven grade scale. Insert new grade: 5.5 5 is not within the seven grade scale. Insert new grade: string 5 is not within the seven grade scale. Insert new grade: 0 The grade has been changed to 0.

Not getting the proper graph comparison using Python
I am trying to compare and get a proper point of intersection between the two CSV files. I am using the graph depiction for better understanding.
But I am getting very diminished image of one graph as compared to another.
See the following:Here is the data: tradevolume.csv
Here is the real graph:
Here is the data: minersrevenue.csv
Here is the real graph:
Here is the program I wrote for comparison:
import pandas as pd import matplotlib.pyplot as plt dat2 = pd.read_csv("tradevolume.csv", parse_dates=['time']) dat3 = pd.read_csv("minersrevenue.csv", parse_dates=['time']) dat2['timeDiff'] = (dat2['time']  dat2['time'][0]).astype('timedelta64[D]') dat3['timeDiff'] = (dat3['time']  dat3['time'][0]).astype('timedelta64[D]') fig, ax = plt.subplots() ax.plot(dat2['timeDiff'], dat2['Value']) ax.plot(dat3['timeDiff'], dat3['Value']) plt.show()
I got the output like the following:
As one can see the orange color graph is very low and I could not understand the points as it is lower. I am willing to overlap the graphs and then check.
Please help me make it possible with my existing code, if no alteration required.

Low performance retrieving calendar events in comparison to contacts
I am currently testing some functionality (performance,...) of the graph api (using graph C# sdk) and got curious about something. When I tried to request a large number of calendar events it took a long time compared to when i accessed contacts. The attached image contains a statistic, that compares completion times of large amounts of contacts and calendar events (using graph sdk). I found that the difference between them is quite big even if its just 1000 units that are requested (events: 13s vs. contacts: 2s). The code I used for both requests should be pretty much identical (as seen below). I also tested sending my own HTTPRequests (without graph sdk) but still got similar results.
Since the returned JSONObjects of calendar events and contacts seem not that different in size, i wanted to ask if there is a reason why the contacts can be requested so much faster? And how I could improve the performance for retrieving events?
Code for getting contacts of specific folder:
//request contacts from contactfolder with id = contactFolderId var request = m_graphClient.Me.ContactFolders[contactFolderId].Contacts.Request().Top(1000); var result = await request.GetAsync(); //add result to a list contacts.AddRange(result); //send nextLink request if available var nextPage = result; while (nextPage.NextPageRequest != null) { var nextPageRequest = nextPage.NextPageRequest; nextPage = await nextPageRequest.GetAsync(); contacts.AddRange(nextPage); }
Code for getting calendar events of a specific calendar:
//request events from calendar with id = calendarFolderId var request = m_graphClient.Me.Calendars[calendarFolderId].Events.Request().Top(1000); var result = await request.GetAsync(); //add result to a list events.AddRange(result); //send nextLink request if available var nextPage = result; while (nextPage.NextPageRequest != null) { var nextPageRequest = nextPage.NextPageRequest; nextPage = await nextPageRequest.GetAsync(); events.AddRange(nextPage); }
image:

algorithm to prove that exist a subgraph F
How can you do this kind of proof?
Given a graph G connected and weighted (with no weights negative in the edges), and a subgraph H⊆G, determine if there exists another subgraph F⊆G so that F≠H, VF=VH and ∑e∈EFw(e) = ∑e∈EHw(e), where w is the function of weight. Show that the above problem is in the class NP.Thanks!! I have this Output: An MST tree of G or no spanning tree. STEP 1. Choose a vertex v0 of G. Initialize a subtree T consisting of v0. STEP 2.IfV(T)=n,STOP.(T isanMSTofG.) STEP 3.IfV(T)

RDF Graph Conversion
How can I convert a resource description framework (RDF) graph (stored in triple format) to edge list or adjacency list?
Is it possible to load an RDF graph to NetworkX graph analytics library?

NetworkX: efficiently inducing clique given vertices
Say, I have a list of vertices
[1, 2, 3, 4, 5]
, and they form a clique, is there a fast way to induce edges between them in a networkx graph? The straightforward way I can think of is:from itertools import combinations def induceClique(nxGraph, vertexList): for i,j in combinations(vertexList, 2): nxGraph.add_edge(i, j) return nxGraph
The function is alright, and you do have to add all possible pairs of edges to make sure there is the desired clique, but operating from Python it can get slow when handling long vertex lists. Maybe there is a an inbuilt function for doing this more efficiently as part of the networkx package, perhaps written in C?

How do I delete a specific node attribute in networkx
I want to remove a specific node attribute in networkx.
I know from this answer that we can delete an attribute from all the nodes one by one:
for node in graph: del graph.node[node][attr]
But I was wondering if there is a way to delete a node attribute from all the nodes without having to loop over all the nodes. Something like:
del graph.nodes[attr]