(Ebook) Graph Algorithms For Data Science (MEAP v7) by Toma Bratani
(Ebook) Graph Algorithms For Data Science (MEAP v7) by Toma Bratani
com
https://ebooknice.com/product/graph-algorithms-for-data-
science-meap-v7-50699820
OR CLICK HERE
DOWLOAD EBOOK
https://ebooknice.com/product/graph-algorithms-for-data-science-with-
examples-in-neo4j-55836718
ebooknice.com
https://ebooknice.com/product/vagabond-vol-29-29-37511002
ebooknice.com
ebooknice.com
ebooknice.com
(Ebook) Graph-Theoretic Concepts in Computer Science: 44th
International Workshop, WG 2018, Cottbus, Germany, June
27–29, 2018, Proceedings by Andreas Brandstädt, Ekkehard
Köhler, Klaus Meer ISBN 9783030002558, 9783030002565,
https://ebooknice.com/product/graph-theoretic-concepts-in-computer-
3030002551, 303000256X
science-44th-international-workshop-wg-2018-cottbus-germany-
june-2729-2018-proceedings-7319936
ebooknice.com
https://ebooknice.com/product/graph-data-science-gds-for-
dummies-48372456
ebooknice.com
https://ebooknice.com/product/boeing-b-29-superfortress-1573658
ebooknice.com
Graph Algorithms for Data Science
1. MEAP_VERSION_7
2. Welcome
3. 1_Graphs_and_network_science:_An_introduction
4. 2_Representing_network_structure_-
_design_your_first_graph_model
5. 3_Your_first_steps_with_the_Cypher_query_language
6. 4_Exploratory_graph_analysis
7. 5_Introduction_to_social_network_analysis
8. 6_Projecting_monopartite_networks_with_Cypher_Projection
9. 7_Inferring_co-
occurrence_networks_based_off_bipartite_networks
10. 8_Constructing_a_nearest_neighbor_similarity_network
11. 9_Node_embeddings_and_classification
12. 10_Link_prediction
13. 11_Knowledge_graph_completion
MEAP VERSION 7
Welcome
Thanks for purchasing the MEAP for Graph Algorithms for Data
Science.
This book has been written for anyone with no experience with
graphs to more experienced graph users to augment their
understanding of graph algorithms and their role in the various
analysis. With traditional analytics, you are trying to make sense of
data points, whereas with graph analytics, you are more focused on
analyzing connections between data points. Graph algorithms are
designed to investigate those connections between data points and
help you explore who is well connected, who has the most influence,
how communities form, and more.
Thanks again for your interest and for purchasing the MEAP!
—Tomaž Bratanič
In this book
Networks are everywhere, and they do matter. First of all, where are
these networks? Communication networks are one example. For
example, the internet consists of routers. Routers analyze the
incoming data, determine the optimal path to the destination, and
forward the data to the next device along the route. Another example
are the social media platforms. You use those platforms to connect
with other users. Most of your connections are local, ranging from
your family and friends to coworkers. And then you have some
connections from distant friends that can span oceans and
continents. When you map all those connections, what you end up
with is referred to as a social network.
I hope by now, you have realized that networks are everywhere. You
just have to open your eyes to see them. When looking at the world,
you can spot networks occurring in politics, markets, art, and even
the dependencies between code modules form as a network. If
you’ve ever developed any code beyond Hello World, you probably
imported other libraries or code from your other modules.
The history of graph theory can be traced to the 18th century when
the Swiss mathematician Leonhard Euler solved the Königsberg
bridge problem. [Leonhard Euler, 1736] In that time, seven bridges
spanned over the forked river in Königsberg. According to folklore,
the puzzle arose of whether a person could take a walk through the
town in a way in which they would cross each bridge exactly once.
Euler argued that no such path exists. Euler’s solution is simple, once
you look at the problem from a graph perspective.
The problem of finding a way that crosses every bridge exactly once
turns into finding a path through the graph that traverses every
relationship exactly once. For a walk that crosses every relationship in
a graph exactly once to be possible, either none or precisely two
nodes can have an odd number of edges attached to them. However,
in the Königsberg bridge problem, all nodes have an odd number of
relationships, making a walk that crosses every bridge once
impossible. In solving this puzzle, Euler started a field that is today
known as graph theory.
Figure 1.9. Encoding node position into the embedding space. Copyright
(c) 2017 Manan Shah, SNAP Group
Figure 1.9 demonstrates the idea of encoding nodes in a network into
embedding or euclidian space. In a traditional machine learning
workflow, each data point is represented as a vector of integers or
floating points. The vectors are then fed into a machine learning
model during training and inference. The primary challenge of
machine learning on graphs is finding a way to represent or encode
network structure as a vector to be easily fed into a machine learning
model.
For example, let’s say you have been given the task of predicting a
person’s net worth based on their characteristics and attributes. The
dataset contains features that describe each data point and the
target variable that needs to be predicted. With supervised
classification, the training data contains both the features as well as
the target variable value, which you can use to train your machine
learning or deep neural network model. Once you have trained the
model, you can use it to predict the net worth of previously unseen
data points and examine how well it works.
Figure 1.10. Traditional machine learning approach, where you treat each
data point as independant.
Figure 1.10 shows an example dataset, where each data point is
described by features such as age, hobby, and education. The data
points are considered independent, which means they are not related
or connected. You would then train a machine learning model based
on the available features to predict a person’s net worth.
You might know that people are very interconnected, and many
people will tell you that networking is a vital part of getting more and
better job or other opportunities in life. Since you haven’t encoded
any of the networking attributes as data point features, you will skip
all that information about connections that might help you more
accurately predict a person’s net worth better. Essentially, you treat
each data point as independent and ignore its context. Here is where
graph machine learning and node representation learning come into
play.
Figure 1.11. Add the number of connections each person has as a feature.
Through the practical examples in this book, you will learn how to
spot graph-shaped problems and construct a graph. Next, you will
learn how to calculate and interpret both the local and global node
characteristics like the node degree and the Betweenness centrality.
The last part of the book is dedicated to machine learning on graphs,
where you will learn how to improve your model’s accuracy by
encoding the network’s structure as your data point feature sets.
1.4 Summary
Networks are everywhere and they do matter
A bar or line chart is not regarded as a graph in this book
Problems that require a graph-based approach have
interconnected data points such as self-referencing relationships
in a social network or paths in a transportation network
Sometimes the relationships between data points are not
explicitly defined but can be inferred based on indirect patterns,
as in the example of users purchasing products
Node degree attribute represents the count of relationships a
node has
Node degree is a local characteristic that examines the node’s
direct neighborhood
Graph algorithms like the Betweeness centrality move beyond
the direct neighborhood of a node and inspect the whole
network
Node embedding models are used to automatically encode a
node’s network position as a vector
Encoding network information for a downstream machine
learning task can greatly improve your accuracy
1.5 References
[Shan Xu et al, 2020] Xu CS, Januszewski M, Lu Z, Takemura S-Y,
Hayworth KJ, Huang G, Shinomiya K, Maitin-Shepard J, Ackerman D,
Berg S, et al. A connectome of the adult Drosophila central brain.
bioRxiv. 2020 [accessed 2021 Jan 21]:2020.01.21.911859.
www.biorxiv.org/content/10.1101/2020.01.21.911859v1.
doi:10.1101/2020.01.21.911859
[Albert, R., Jeong, H. & Barabási, 1999] Albert, R., Jeong, H. &
Barabási, AL. Diameter of the World-Wide Web. Nature 401, 130–131
(1999). doi.org/10.1038/43601
Figure 2.3. A directed weighted graph represented with a edge list data
structure
The value of the relationship weight is stored in a separate column.
You could also store additional information about the relationship in
the edge list, such as the time component. One limitation of the edge
list is that it does not allow isolated nodes to be present. Isolated
nodes are nodes without any relationships. This limitation can be
solved by introducing a node list next to the edge list.
Figure 2.4. With addition of the node list, you can represent isolated
nodes in a network
By introducing the node list next to the relationship list, you can
describe networks with isolated nodes present. The network in Figure
2.4 has an isolated node E. Node E is isolated because it is described
in the node list but has no entries in the relationship list. The node
list can also be expanded to store various properties of the nodes.
For example, the node list in Figure 2.4 contains information about
nodes' age. Node and relationship lists are very frequently used as
input to network visualization tools. When trying to visualize a
network, you could store the size and the color of the visualized node
as additional properties in the node list. Node and edge lists are
useful when you have a defined graph structure that doesn’t require
additional data manipulations or transformations. However, in
practice, I have noticed that you often need to transform and
manipulate the network data to fit your problem best. A typical
example would be translating indirect relationships into direct ones.
While you could use a scripting language for data transformations
directly with node and edge lists, I recommend using a graph
database and dedicated graph-pattern query languages.
Before you learn more about graph databases, we will also look at
the text representation of simple networks. The text representation of
networks comes in handy when you want to communicate the
network structure via text quickly. We will borrow the syntax from the
Cypher query language. Cypher’s syntax provides a visual way to
match patterns of nodes and relationships in the graph using ASCII-
Art syntax. Its syntax describing nodes and relationships is also the
basis for the future Graph Query Language (GQL), which aims to
unify the graph-pattern query language the same as SQL did for
relational databases. An example node representation in Cypher looks
like the following:
(:Person {name:"Thomas"})
Both Thomas and Elaine are persons, and they are friends since
2016. If you look carefully, you can observe a direction indicator of
the relationship at the end of the text representation. With it, you can
differentiate between directed and undirected relationships. If you
want to describe the friendship relationship as undirected, all you
have to do is omit the relationship direction indicator.
-[:FRIEND{since:"2016"}]-
You can observe that you are doing a complete data normalization by
representing a network with an RDF graph model. RDF’s abstraction
level is a triple, where the subject and object of the triple are
represented as nodes, and the predicate is represented as a
relationship. Consequently, there is no internal structure available on
the nodes and relationships, meaning that you are not dealing with
internal node or relationship properties. but store the properties as a
separate node with a literal value. Although, in practice, you might
consider literal node values as node attributes, the underlying triple
data structure treats them as separate nodes. In the example in
Figure 2.7, the node Thomas is disambiguated by using a resource
identifier "http://schema.org/Thomas". Resource identifiers follow the
structure of a URI. For this example, I have made up the resource
identifiers values. I have also omitted the schema.org prefix in the
network visualization for readability purposes. The node Thomas has
three relationships. Two of them point to another resource node,
while the age relationship is pointing to a literal value and can be
interpreted as a node attribute.
Figure 2.8. WikiData web page with information about Tom Hanks
available at www.wikidata.org/wiki/Q2263
Tom Hanks is a resource node in the WikiData graph. Its id is Q2263
and in the Figure 2.8 is always regarded as the subject of the triple
data structure. That being said, this does not limit Tom Hanks to
appear as a object of the triple data structure in any other examples.
You can observe that Tom Hanks is a citizen of both the United States
of America and Greece.
As you can observe, the key difference from the RDF approach to
graph modeling is that labeled-property graph(LPG) supports both
node and relationship properties stored as key-value pairs. In the
example in Figure 2.9, the age information is now stored as an
internal node property. Another key difference is that you can group
or categorize nodes into distinct sets using a node label. In Figure
2.9, both Thomas and Elaine nodes have a label that indicates they
are categorized as persons. You might have observe that the Cypher
query syntax you learned before is used to describe LPG model
domain.
In some domain use cases, you might still want to represent literal
values as separate nodes. A typical example is the fraud detection
scenario, where you are interested in examining customers who
share the same address, social security number, or phone number.
Nothing is stopping you from modeling your graph where some literal
values are represented as separate nodes. The graph model depends
on your task, and with the LPG model, you can represent a literal
Random documents with unrelated
content Scribd suggests to you:
“The cavalry barracks, as a whole, are the least overcrowded, and
have the freest external movement of air. Next come the infantry; and
the most crowded and the least ventilated externally are the Guards’
barracks; so that the mortality from consumption, which follows the
same order of increase in the different arms, augments with increase
of crowding and difficulty of ventilation.”[18]
Her own well-trained mind was in extreme contrast with the type of mind
which she describes in the following story:—
All her teaching, so far as I know it, is clearly at first-hand and carefully
sifted. It is as far as possible from that useless kind of doctrine which is a
mere echo of unthinking hearsay. For instance, how many sufferers she must
have saved from unnecessary irritation by the following reminder to nurses:—
“Of all parts of the body, the face is perhaps the one which tells the
least to the common observer or the casual visitor.
“I have known patients dying of sheer pain, exhaustion, and want
of sleep, from one of the most lingering and painful diseases known,
preserve, till within a few days of death, not only the healthy colour of
the cheek, but the mottled appearance of a robust child. And scores of
times have I heard these unfortunate creatures assailed with, ‘I am
glad to see you looking so well.’ ‘I see no reason why you should not
live till ninety years of age.’ ‘Why don’t you take a little more exercise
and amusement?’—with all the other commonplaces with which we
are so familiar.”
And then, again, how like her it is to remind those who are nursing that “a
patient is not merely a piece of furniture, to be kept clean and arranged
against the wall, and saved from injury or breakage.”
She was one of the rare people who realized that truth of word is partly a
question of education, and that many people are quite unconscious of their
lack of that difficult virtue. “I know I fibbs dreadful,” said a poor little servant
girl to her once. “But believe me, miss, I never finds out I have fibbed until
they tell me so!” And her comment suggests that in this matter that poor little
servant girl by no means stood alone.
She worked very hard. Her books and pamphlets[19] were important, and
her correspondence, ever dealing with the reforms she had at heart all over
the world, was of itself an immense output.
Those who have had to write much from bed or sofa know only too well the
abnormal fatigue it involves, and her labours of this kind seem to have been
unlimited.
How strongly she sympathized with all municipal efforts, we see in many
such letters as the one to General Evatt, given him for electioneering
purposes, but not hitherto included in any biography, which we are allowed to
reproduce here:—
And also the following letter written to the Buckinghamshire County Council
in 1892, begging them to appoint a sanitary committee:—
“We must create a public opinion which will drive the Government,
instead of the Government having to drive us—an enlightened public
opinion, wise in principles, wise in details. We hail the County Council
as being or becoming one of the strongest engines in our favour, at
once fathering and obeying the great impulse for national health
against national and local disease. For we have learned that we have
national health in our own hands—local sanitation, national health.
But we have to contend against centuries of superstition and
generations of indifference. Let the County Council take the lead.”
And how justly, how clearly, she was able to weigh the work of those who
had borne the brunt of sanitary inquiry in the Crimea, with but little except
kicks for their pains, may be judged by the following sentences from a letter
to Lady Tulloch in 1878:—
“My Dear Lady Tulloch,—I give you joy, I give you both joy, for this
crowning recognition of one of the noblest labours ever done on
earth. You yourself cannot cling to it more than I do; hardly so much,
in one sense, for I saw how Sir John MacNeill’s and Sir A. Tulloch’s
reporting was the salvation of the army in the Crimea. Without them
everything that happened would have been considered ‘all right.’
“Mr. Martin’s note is perfect, for it does not look like an
afterthought, nor as prompted by others, but as the flow of a
generous and able man’s own reflection, and careful search into
authentic documents. Thank you again and again for sending it to me.
It is the greatest consolation I could have had. Will you remember me
gratefully to Mr. Paget, also to Dr. Balfour? I look back upon these
twenty years as if they were yesterday, but also as if they were a
thousand years. Success be with us and the noble dead—and it has
been success.—Yours ever,
“Florence Nightingale.”
We see from this letter how warmly the old memories dwelt with her, even
while her hands were full of good work for the future.
The death of Lord Herbert in 1868 had been a blow that struck very deeply
at her health and spirits.
In all her work of army reform she had looked up to him as her “Chief,”
hardly realizing, perhaps, how much of the initiating had been her own. Their
friendship, too, had been almost lifelong, and in every way ideal. The whole
nation mourned his loss, but only the little intimate group which centred in his
wife and children and those dearest friends, of whom Miss Nightingale was
one, knew fully all that the country had lost in him.
It may be worth while for a double reason to quote here from Mr.
Gladstone’s tribute at a meeting held to decide on a memorial.
“To him,” said Gladstone, “we owe the commission for inquiry into
barracks and hospitals; to him we are indebted for the reorganization
of the medical department of the army. To him we owe the
commission of inquiry into, and remodelling the medical education of,
the army. And, lastly, we owe him the commission for presenting to
the public the vital statistics of the army in such a form, from time to
time, that the great and living facts of the subject are brought to
view.”
Lord Herbert had toiled with ever-deepening zeal to reform the unhealthy
conditions to which, even in times of peace, our soldiers had been exposed—
so unhealthy that, while the mortality lists showed a death of eight in every
thousand for civilians, for soldiers the number of deaths was seventeen per
thousand. And of every two deaths in the army it was asserted that one was
preventable. Lord Herbert was the heart and soul of the Royal Commission to
inquire into these preventable causes, and through his working ardour the
work branched forth into four supplementary commissions concerning
hospitals and barracks. When he died, Miss Nightingale not only felt the pang
of parting from one of her oldest and most valued friends, but she also felt
that in this cause, so specially dear to her heart, she had lost a helper who
could never be replaced, though she dauntlessly stood to her task and helped
to carry on his work.
CHAPTER XXI.
Multifarious work and many honours—Jubilee Nurses—Nursing Association
—Death of father and mother—Lady Verney and her husband—No
respecter of persons—From within four walls—South Africa and
America.
If there had been any hope at first that Miss Nightingale might
grow strong enough to stand visibly among those who were being
trained as nurses by the fund raised in her honour, that hope was
now past, and when the great new wing of St. Thomas’s was built—
the finest building for its purpose in Europe—the outward reins of
government had to be delivered over into the hands of another,
though hers was throughout the directing hand. And the results of
her work are written in big type upon the page of history.
In India and America she is acclaimed as an adored benefactress,
but what has she not done for our own country alone? To sum up
even a few of the points on which I have touched: she initiated sick
nursing among the poor, through her special appeal was built the
Central Home for Nurses, she was the pioneer in the hygienic work
of county councils, and, besides the great nursing school at St.
Thomas’s, to her was largely due the reform of nursing in
workhouses and infirmaries. And in 1890, with the £70,000 of the
Women’s Jubilee Fund, the establishment of the Queen’s Nurses
received its charter.
In affairs of military nursing it is no exaggeration to say that she
was consulted throughout the world. America came to her in the
Civil War; South Africa owed much to her; India infinitely more; and
so vital have been the reforms introduced by Lord Herbert and
herself that even as early as 1880, when General Gordon was
waging war in China during the Taiping Rebellion, the death-rate as
compared with the Crimea was reduced from sixty per cent. to little
more than three in every hundred yearly.[22]
We have seen that, though she was so much more seriously
broken in health than any one at first realized, that did not prevent
her incessant work, though it did in the end make her life more or
less a hidden life, spent within four walls, and chiefly on her bed.
Yet from those four walls what electric messages of help and
common sense were continuously flashing across the length and
breadth of the world! She was regarded as an expert in her own
subjects, and long before her Jubilee Fund enabled her to send forth
the Queen’s Nurses, she was, as we have already seen, busy writing
and working to improve not only nursing in general, but especially
the nursing of the sick poor; and unceasingly she still laboured for
the army.
Repeated mention has been made of General Evatt, to whose
memory of Miss Nightingale I am much indebted.
General Evatt served in the last Afghan campaign, and what he
there experienced determined him to seek an interview, as soon as
he returned to England, with her whom he regarded as the great
reformer of military hygiene—Florence Nightingale. In this way and
on this subject there arose between them a delightful and enduring
friendship. Many and many a time in that quiet room in South Street
where she lay upon her bed—its dainty coverlet all strewn with the
letters and papers that might have befitted the desk or office of a
busy statesman, and surrounded by books and by the flowers that
she loved so well—he had talked with her for four hours on end,
admiring with a sort of wonder her great staying power and her big,
untiring brain.
He did not, like another acquaintance of mine, say that he came
away feeling like a sucked orange, with all hoarded knowledge on
matters great and small gently, resistlessly drawn from him by his
charming companion; but so voracious was the eager, sympathetic
interest of Miss Nightingale in the men and women of that active
world whose streets, at the time he learned to know her, she no
longer walked, that no conversation on human affairs ever seemed,
he said, to tire her.
And her mind was ever working towards new measures for the
health and uplifting of her fellow-creatures.
We have seen how eager she was to use for good every municipal
opportunity, but she did not stop at the municipality, for she knew
that there are many womanly duties also at the imperial hearth; and
without entering on any controversy, it is necessary to state clearly
that she very early declared herself in favour of household suffrage
for women, and that “the North of England Society for Women’s
Suffrage is the proud possessor of her signature to an address to Mr.
Disraeli, thanking him for his favourable vote in the House of
Commons, and begging him to do his utmost to remove the injustice
under which women householders suffered by being deprived of the
parliamentary vote.”[23]
Frere had seen that the filthy condition of many of the roads, after
the passing of animals and the failure to cleanse from manure, was
of itself a source of poison, though the relation between garbage
and disease-bearing flies was then less commonly understood, and
he was never tired of urging the making of decent roads; but this,
he knew, was only a very small part of the improvements needed.
His correspondence with Miss Nightingale began in 1867, and in
that and the five following years they exchanged about one hundred
letters, chiefly on sanitary questions.
It was part of her genius always to see and seize her opportunity,
and she rightly thought that, as she says in one of her letters, “We
might never have such a favourable conjunction of the larger planets
again:
“You, who are willing and most able to organize the machinery
here; Sir John Lawrence, who is able and willing, provided only he
knew what to do; and a Secretary of State who is willing and in
earnest. And I believe nothing would bring them to their senses in
India more than an annual report of what they have done, with your
comments upon it, laid before Parliament.”
In order to set in motion the machinery of a sanitary department
for all India, a despatch had to be written, pointing out clearly and
concisely what was to be done.
Frere consulted Miss Nightingale at every point about this
despatch, but spoke of the necessity for some sort of peg to hang it
on—“not,” he said, “that the Secretary of State is at all lukewarm,
nor, I think, that he has any doubt as to what should be said, or how
—that, I think, your memoranda have fixed; the only difficulty is as
to the when....
“No governor-general, I believe, since the time of Clive has had
such powers and such opportunities, but he fancies the want of
progress is owing to some opposing power which does not exist
anywhere but in his own imagination.
“He cannot see that perpetual inspection by the admiral of the drill
and kit of every sailor is not the way to make the fleet efficient, and
he gets disheartened and depressed because he finds that months
and years of this squirrel-like activity lead to no real progress.”
The despatch with its accompanying documents went to Miss
Nightingale for her remarks before it was sent out. Her commentary
was as follows:—
It was a great work, and it might have been delayed for scores of
years, with a yearly unnecessary waste of thousands of lives, if she
had not initiated it.
Florence Nightingale in her Last Days.
Her words to Sir Bartle Frere at the outset had been: “It does
seem that there is no element in the scheme of government (of
India) by which the public health can be taken care of. And the thing
is now to create such an element.”
As early as 1863, in her “Observations on the Sanitary State of the
Army in India,” she had written:—
How far she was ahead of her time becomes every day more
obvious; for every day the results of her teaching are gradually
making themselves felt. For example, it can no longer, without
qualification, be said, as she so truly said in her own day, that while
“the coxcombries of education are taught to every schoolgirl” there
is gross ignorance, not only among schoolgirls, but also even among
mothers and nurses, with regard to “those laws which God has
assigned to the relations of our bodies with the world in which He
has put them. In other words, the laws which make these bodies,
into which He has put our minds, healthy or unhealthy organs of
those minds, are all but unlearnt. Not but that these laws—the laws
of life—are in a certain measure understood, but not even mothers
think it worth their while to study them—to study how to give their
children healthy existences. They call it medical or physiological
knowledge, fit only for doctors.”
In her old age, loved and honoured far and wide, she toiled on
with all the warm enthusiasm of a girl, and the ripe wisdom of
fourscore years and ten spent in the service of her one Master, for
she was not of those who ever tried to serve two. And when she
died at No. 10 South Street, on August 10, 1910—so peacefully that
the tranquil glow of sunset descended upon her day of harvest—the
following beautiful incident was recorded in Nursing Notes, to whose
editor I am specially indebted for bringing to my notice the verses in
which the story is told[26]:—
F. S.
CHAPTER XXIII.
A brief summing up.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebooknice.com