Download PDF Graph algorithms for data science: with examples in neo4j 1st edition tomaž bratanic fu
Visit to download the full and correct content document: https://textbookfull.com/product/graph-algorithms-for-data-science-with-examples-in-n eo4j-1st-edition-tomaz-bratanic/
More products digital (pdf, epub, mobi) instant download maybe you interests ...
Graph Algorithms Practical Examples in Apache Spark and Neo4j 1st Edition Mark Needham
Modern Data Mining Algorithms in C++ and CUDA C: Recent Developments in Feature Extraction and Selection Algorithms for Data Science 1st Edition Timothy Masters
For online information and ordering of these and other Manning books, please visit www.manning.com. The publisher offers discounts on these books when ordered in quantity.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.
♾ Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine.
Manning Publications Co. 20 Baldwin Road Technical PO Box 761
Shelter Island, NY 11964
Development editor: Dustin Archibald
Technical editor: Arturo Geigel
Technical development editor: Ninoslav Cerkez
Review editor: Aleksandar Dragosavljević
Production editor: Deirdre S. Hiam
Copy editor: Christian Berk
Proofreader: Katie Tennant
Technical proofreader: Jerry Kuch
Typesetter: Dennis Dalinnik
Cover designer: Marija Tudor
ISBN: 9781617299469
contents
front matter foreword preface acknowledgments about this book about the author about the cover illustration
Part 1 Introduction to graphs
1 Graphs and network science: An introduction
1.1 Understanding data through relationships
1.2 How to spot a graph-shaped problem
Self-referencing relationships
Pathfinding networks
Bipartite graphs
Complex networks
2 Representing network structure: Designing your first graph model
2.1 Graph terminology
Directed vs. undirected graph
Weighted vs. unweighted graphs
Bipartite vs. monopartite graphs
Multigraph vs. simple graph
A complete graph
2.2 Network representations
Labeled-property graph model
2.3 Designing your first labeled-property graph model
Follower network
User-tweet network
Retweet network
Representing graph schema
2.4 Extracting knowledge from text
Links Hashtags
Mentions
Final Twitter social network schema
Part 2 Social network analysis
3 Your first steps with Cypher query language
3.1 Cypher query language clauses
CREATE clause
MATCH clause
WITH clause
SET clause
REMOVE clause
DELETE clause
MERGE clause
3.2 Importing CSV files with Cypher
Clean up the database
Twitter graph model
Unique constraints
LOAD CSV clause
Importing the Twitter social network
3.3 Solutions to exercises
4 Exploratory graph analysis
4.1 Exploring the Twitter network
4.2 Aggregating data with Cypher query language
Time aggregations
4.3 Filtering graph patterns
4.4 Counting subqueries
4.5 Multiple aggregations in sequence
4.6 Solutions to exercises
5 Introduction to social network analysis
5.1 Follower network
Node degree distribution
5.2 Introduction to the Neo4j Graph Data Science library
Graph catalog and native projection
5.3 Network characterization
Weakly connected component algorithm
Strongly connected components algorithm
Local clustering coefficient
5.4 Identifying central nodes
PageRank algorithm
Personalized PageRank algorithm
Dropping the named graph
5.5 Solutions to exercises
6 Projecting monopartite networks
6.1 Translating an indirect multihop path into a direct relationship
Cypher projection
6.2 Retweet network characterization
Degree centrality
Weakly connected components
6.3 Identifying the most influential content creators
Excluding self-loops
Weighted PageRank variant
Dropping the projected in-memory graph
6.4 Solutions to exercises
7 Inferring co-occurrence networks based on bipartite networks
7.1 Extracting hashtags from tweets
7.2 Constructing the co-occurrence network
Jaccard similarity coefficient
Node similarity algorithm
7.3 Characterization of the co-occurrence network
Node degree centrality
Weakly connected components
7.4 Community detection with the label propagation algorithm
7.5 Identifying community representatives with PageRank
Dropping the projected in-memory graphs
7.6 Solutions to exercises
8 Constructing a nearest neighbor similarity network
8.1 Feature extraction
Motifs and graphlets
Betweenness centrality
Closeness centrality
8.2 Constructing the nearest neighbor graph
Evaluating features
Inferring the similarity network
8.3 User segmentation with the community detection algorithm
8.4 Solutions to exercises
Part 3 Graph machine learning
9 Node embeddings and classification
9.1 Node embedding models
Homophily vs. structural roles approach
Inductive vs. transductive embedding models
9.2 Node classification task
Defining a connection to a Neo4j database
Importing a Twitch dataset
9.3 The node2vec algorithm
The word2vec algorithm
Random walks
Calculate node2vec embeddings
Evaluating node embeddings
Training a classification model
Evaluating predictions
9.4 Solutions to exercises
10 Link prediction
10.1 Link prediction workflow
10.2 Dataset split
Time-based split
Random split
Negative samples
10.3 Network feature engineering
Network distance
Preferential attachment
Common neighbors
Adamic-Adar index
Clustering coefficient of common neighbors
10.4 Link prediction classification model
Missing values
Training the model
Evaluating the model
10.5 Solutions to exercises
11 Knowledge graph completion
11.1 Knowledge graph embedding model
Triple
TransE
TransE limitations
11.2 Knowledge graph completion
Hetionet
Dataset split
Train a PairRE model
Drug application predictions
Explaining predictions
11.3 Solutions to exercises
12 Constructing a graph using natural language processing techniques
12.1 Coreference resolution
12.2 Named entity recognition
Entity linking
12.3 Relation extraction
12.4 Implementation of information extraction pipeline
SpaCy
Corefence resolution
End-to-end relation extraction
Entity linking
External data enrichment
12.5 Solutions to exercises
Appendix The Neo4j environment references index
front matter foreword
When you read this book, I hope you are as astonished by the power of relationships and connected information as I was when I first met Emil Eifrém, one of the founders of Neo4j, 15 years ago on a geek cruise on the Baltic Sea. Ten years later, a similarly inspiring and impactful meeting happened when Tomaž and I met for the first time in person in London. He’d been active in the Neo4j community for a while. After that meeting, his contributions skyrocketed, initially helping test and document the predecessor of the Graph Data Science library and at the same time becoming a prolific author on data science topics related to graphs, NLP, and their practical applications (bratanictomaz.medium.com). Tomaž must have published hundreds of articles by the time we were contacted by Manning to discuss creating a book on graph analytics—the one you’re holding right now. Tomaž was the obvious choice to become its author, and he did an amazing job, distilling his experience, educational writing style, and real-world examples into an insightful and entertaining book. This book is a journey into the hidden depths of connected data using graph algorithms and new ML techniques—like node embeddings—and graph machine learnings, like link prediction and node classification, many of which now find
applications in areas like vector search or large-language models based on transformers like GPT.
I’ve often said that in the real world, there is no such thing as isolation; everything is connected—people, events, devices, content and products, art, history, politics, markets, biological pathways, and climate tipping points, from the smallest subatomic particles (relational quantum dynamics) to the largest structures in the universe (galactic pathways). Humans have accelerated the volume and density of those connections by adding information technology, the internet, social networks, mobile computing, IoT, and widespread use of ML models. Our lives depend on all those networks working properly, even if we are unaware of most of them. How does one make sense of all these obvious and hidden relationships, which add context and meaning to all individual data points? Sure, you can query for patterns that you already know, but what about the unknown unknowns? This is where graph analytics and graph-based ML techniques shine. They help you find the insights you need. We start with centrality or clustering algorithms, like PageRank or Louvain, which can be used for unsupervised learning about the structure and importance of elements in your data. One of my favorite examples is still Network of Thrones by Andrew Beveridge, where he used spatial closeness of characters in the naturallanguage-processed texts of the Game of Thrones books to determine importance, groups, and dependencies. Those algorithms achieved results impressively similar to what you as a human would find if you read the books. Using results from those algorithms as feature vectors in your ML models
already improves the accuracy of your predictions, as they capture the context of your entities both structurally and behaviorally. But you can even go a step further and explicitly compute embeddings for nodes based on graph operations. One of the first algorithms in this space was node2vec, which used the word2vec embeddings on paths from random walks out of your starting point (an approach conceptually similar to PageRank). Now, we are much further along, with knowledge graph embeddings using graphs as inputs and outputs that can make real use of the richness of connected data. And in current ML papers and architectures, you will commonly find mentions of graph structures and algorithms, so this is now a kind of foundational technology. Tomaž will take you along the learning journey, starting from data modeling, ingestion, and querying; to the first applications of graph algorithms; all the way to extracting knowledge graphs from text using NLP; and, finally, utilizing embeddings of nodes and graphs in ML training applications. Enjoy the ride to its graph epiphany, and I hope you will come out on the other side a graph addict, as we all turned out to be.
M
H , senior director of user innovation, Neo4j
preface
I transitioned to software development in my professional path about seven years ago. As if the universe had a plan for me, I was gently pushed toward graphs in my first developer job. I am probably one of the few people who can
claim Cypher query language was the first language they were introduced to and started using, even before SQL or any scripting language, like Python. Kristjan Pećanac, my boss at the time, foresaw that graphs, particularly labeledproperty graphs, were the future.
At the time, there weren’t many native graph databases out there, so Neo4j felt like a clear-cut choice. The more I learned about graphs and Neo4j, the more I liked them. However, one thing was rather obvious. Even though there were so many awesome things I could do with graphs, the documentation could have been much better. I started writing a blog to showcase all the remarkable things one can do with graphs and to spare people the effort of searching the internet and source code to learn how to implement various features and workflows. Additionally, I treated the blog as a repository of code I could use and copy in my projects.
Fast-forward five years: after more than 70 published blog posts, I authored a post about combining natural language processing and graphs. It was probably my best post to date, and interestingly, I wrote in the summary that if I ever wrote a book, that post would be a chapter in it. Life is a combination of lucky coincidences. Michael Hunger read my NLP post and asked if I was serious about writing a book. I half-jokingly replied that writing a book might be a good idea and would help me advance in my career. Michael took it seriously, and we met with Manning the next month. The rest is history, and the book before you is the result of
my journey to make graphs and graph data science easier to learn, understand, and implement in your projects.
acknowledgments
At first, I didn’t realize how much work goes into writing a book. After writing this book, I have gained considerable respect for any author who has published a book. Luckily, I had great people around me who helped improve the book with their ideas, reviews, and feedback.
First, I would like to thank my development editor at Manning, Dustin Archibald, for helping me become a better writer and guiding and introducing me to the many concepts that make a great book even better. Thank you as well, Deirdre Hiam, my project editor; Christian Berk, my copyeditor; Katie Tennant, my proofreader; and Aleksandar Dragosavljević, my reviewing editor. I would also like to thank, in no particular order, the many people who contributed their ideas and helped with reviews: Ljubica Lazarevic, Gopi Krishna Phani Dathar, David Allen, Charles Tapley Hoyt, Pere-Lluís Huguet Cabot, Amy Hodler, Vlad Batushkov, Jaglan Gaurav, Megan Tomlin, Al Krinker, Andrea Paciolla, Atilla Ozgur, Avinash Tiwari, Carl Yu, Chris Allan, Clair Sullivan, Daivid Morgan, Dinesh Ghanta, Hakan Lofquist, Ian Long, Ioannis Atsonios, Jan Pieter Herweijer, Karthik Rajan, Katie Roberts, Lokesh Kumar, Marcin Sȩk, Mark Needham, Mike Fowler, Ninoslav Cerkez, Pethuru Raj, Philip Patterson, Prasad Seemakurthi, Richard Tobias, Sergio Govoni, Simone Sguazza, Subhash Talluri, Sumit Pal, Syed
Nouman Hasany, Thomas Joseph Heiman, Tim Wooldridge, Tom Kelly, Viron Dadala, and Yogesh Kulkarni. I would also like to extend my gratitude to Jerry Kuch and Arturo Geigel for their invaluable technical comments. Arturo is an independent researcher from Puerto Rico. He received his PhD in computer science from Nova Southeastern University, is recognized for being the inventor of Neural Trojans, and currently carries out research machine learning, graph theory, and technological analysis.
about this book
Graph Algorithms for Data Science was written to help you incorporate graph analytic toolkits into your analytics workflows. The idea behind the book is to take a person who has never heard of graphs before and walk them through their first graph model and graph aggregations, eventually arriving at more advanced, graph, machine learning workflows, like node classification and link prediction.
Who should read this book
Graph Algorithms for Data Science is intended for data analysts and developers looking to augment their data analytics toolkit by incorporating graph algorithms to explore relationships between data points. This book is perfect for individuals with a basic understanding of Python and machine learning concepts, like classification models, eager to enhance their data analysis capabilities. With its
structured approach, this book caters to a wide range of readers, aiding junior analysts in building a strong foundation in graph algorithms while also providing more experienced analysts with new perspectives and advanced techniques, thereby broadening their data science competencies.
How this book is organized
The book has 3 sections that cover 12 chapters. Part 1 introduces graphs and walks you through a graph modeling task:
Chapter 1 introduces the concept of graphs and how to spot a graph-shaped problem. It also introduces the types of graph algorithms you will learn about throughout the book.
Chapter 2 starts by presenting basic graph terminology you can use to describe a graph. It continues by introducing a labeled-property graph model and walking you through a graph modeling task.
Part 2 introduces Cypher query language and frequently used graph algorithms:
Chapter 3 covers the basic Cypher query language syntax and clauses. It also demonstrates how to import a graph from CSV files.
Chapter 4 walks you through an exploratory graph analysis. You will learn how to retrieve, filter, and aggregate data using Cypher query language.
Chapter 5 demonstrates how to use Cypher query language and graph algorithms to characterize a graph. It also shows how to find the most important nodes by using the PageRank algorithm.
Chapter 6 illustrates how to transform indirect relationships between data points to a direct one, which can be used as input to graph algorithms. Additionally, it introduces the weighted variants of some graph algorithms, like node degree and PageRank.
Chapter 7 displays how to project a co-occurrence network, where the number of common neighbors between a pair of nodes defines how similar they are.
Chapter 8 demonstrates how to characterize node roles in the network using various features and metrics. Later in the chapter, you will learn how to construct a knearest neighbor graph and find communities of nodes with similar roles.
Part 3 covers more advanced graph machine learning workflows, such as node classification and link prediction:
Chapter 9 introduces node embedding models and walks you through a node classification task.
Chapter 10 walks you through link prediction tasks, where you use Cypher query language to extract relevant features and use them to train a link prediction model.
Chapter 11 covers the difference between link prediction in simple versus complex graphs and introduces knowledge graph embedding models, which can be used to predicts links in complex networks. Chapter 12 shows how to construct a graph using natural language processing techniques, like named entity recognition and relationship extraction.
In overview, the first two chapters introduce you to basic graph theory and terminology while also discussing the Twitter graph model that will be used in chapters 3-8. Chapters 3 and 4 are intended to familiarize you with Cypher query language. The following chapters are designed as individual analyst assignments, introducing relevant graph algorithms where needed.
About the code
This book contains many examples of source code both in numbered listings and in line with normal text. In both cases, source code is formatted in a fixed-width font like this to separate it from ordinary text. Sometimes code is also in bold to highlight code that has changed from previous steps in the chapter, such as when a new feature adds to an existing line of code. In many cases, the original source code has been reformatted; we’ve added line breaks and reworked indentation to accommodate the available page space in the book. In rare cases, even this was not enough, and listings include line-continuation markers (➥). Additionally, comments in the source code
have often been removed from the listings when the code is described in the text. Code annotations accompany many of the listings, highlighting important concepts.
The source code for chapters 3-8 is only available as part of the book, while the source code for chapters 9-12 is provided as Jupyter notebooks on this GitHub repository: https://github.com/tomasonjo/graphs-network-science.
liveBook discussion forum
Purchase of Graph Algorithms for Data Science includes free access to liveBook, Manning’s online reading platform. Using liveBook’s exclusive discussion features, you can attach comments to the book globally or to specific sections or paragraphs. It’s a snap to make notes for yourself, ask and answer technical questions, and receive help from the author and other users. To access the forum, go to https://livebook.manning.com/book/graph-algorithms-fordata-science/discussion. You can also learn more about Manning’s forums and the rules of conduct at https://livebook.manning.com/discussion.
Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We suggest you try asking him some challenging questions lest his interest stray! The forum and the archives of previous discussions will be
accessible from the publisher’s website as long as the book is in print.
about the author
T B is a network scientist at heart, working at the intersection of graphs and machine learning. He has applied these graph techniques to projects in various domains, including fraud detection, biomedicine, businessoriented analytics, and recommendations.
about the cover illustration
The figure on the cover of Graph Algorithms for Data Science is “Femme de Lima” or “Woman from Lima,” taken from a collection by Jacques Grasset de Saint-Sauveur, published in 1797. Each illustration is finely drawn and colored by hand.
In those days, it was easy to identify where people lived and what their trade or station in life was just by their dress. Manning celebrates the inventiveness and initiative of the computer business with book covers based on the rich diversity of regional culture centuries ago, brought back to life by pictures from collections such as this one.
Part 1 Introduction to graphs
Have you ever marveled at the complex connections between routers that make the internet, navigated through an unfamiliar city using a mapping app, or discovered a hidden gem through a recommendation engine? If so, you’ve experienced the power of graph algorithms and data science in action. Graphs are everywhere, underlying the complex connections and relationships that shape our world, from social networks and the internet to biological systems and transportation networks. In the last couple of years, the field of graph data science has grown exponentially, driven by the increasing availability of large datasets and rapid advancements in computing power. The heart of these applications lies in the art of modeling, analyzing, and mining data to uncover hidden patterns and gain valuable insights. In essence, graph data science focuses on exploring the relationships and interactions between data points instead of studying them individually, as this approach allows for a deeper understanding of the context and significance of each element within the larger network. The first part of this book will introduce you to the fascinating world of graph algorithms and data science, equipping you with the fundamental knowledge to harness their potential and transform your data-driven projects. Chapter 1 provides an overview of identifying graph-related problems and offers a categorization of graph algorithms that will be used throughout the book. Chapter 2 introduces graph terminology and then dives straight into the action,
showing how to approach graph modeling through a practical example.
1 Graphs and network science: An introduction
This chapter covers
Introducing graph modeling and visualizations
Understanding data through relationships
Spotting graph-shaped problems
If you have ever done any analysis, you have probably used a table representation of data, like an Excel spreadsheet or SQL database. Additionally, if you are dealing with large numbers of documents, you might have used parquet format or JSON-like objects to represent the data.
Figure 1.1 shows table and JSON document representations of orders. For example, the table contains information about four orders of various dates and products. Table representations efficiently perform aggregations, like aggregating the total revenue or counting the number of new customers. Likewise, document structures can be great for storing vast amounts of data. In figure 1.1, a JSON object is used to store information about an online order, such as the order status, shipping address, and more. However, data analytics tools designed for tables or documents frequently overlook the relationships between data points.
Another random document with no related content on Scribd:
producing a lovely colored light. These glow-worms are somewhat rare in this country, but are common in England, where our fire-fly is unknown. The glow-worms of tropical countries are as large as good-sized caterpillars, and give out a light of corresponding size.
Some of the beetles of tropical countries are much more radiant than the glow-worms. They have a bright ring around their bodies, which sheds such a light that it is said that the negroes use them for lamps. These negroes we are told by travelers make small round cages of thin wooden slats placed near each other, and closed at the top and bottom. In these they put several beetles, and thus light up their rooms free of cost.
THE GREAT LANTERN FLY
But the most splendidly illuminated insect in the world is the great lantern fly. Its monstrous head is a blaze of light. When it flies through the air it is like a streamer of fire. When it alights upon a leaf, with its beautiful wings outstretched, and its head gleaming with starlike rays, that light up everything for some little distance, it is a gorgeous sight indeed.
But, although this insect is so bright-headed it is not so wise as some others whose heads are not brilliant at all. Perhaps this head is
like some shops we have seen, where pretty much all the furniture is on the outside.
OWLS ON A FROLIC.
THE OWLS UPSETTING THE LAMP.
The owls are abroad on a mad carouse, Waking the echoes far and wide; They whirl in a crowd through the ruined church,
Or up to the belfry glide.
The little screech-owl makes a horrid din; While the great white owl looks wise; And the horned owl nods his head, and blinks; As around the lamp he flies.
The lamp is a cup, half filled with oil, That swings from a broken beam; And, over the traveler sleeping below, It throws but a dusky gleam.
The owls have no fear of the burning wick— ’Tis only a cotton loop— They’re after the oil in the swinging cup, And down on its brim they swoop.
The weary traveler, sound asleep, Hears naught of the noise o’erhead, A rickety chair as a bedstead serves, His overcoat is his bed.
With the sweep of the wings the lamp upsets, While the gurgling oil o’erflows With a drip, and a rush, on the great owl’s tail, A splash on the traveler’s nose.
He’s up in a trice, and, seizing a broom, He arms himself for a fight. But all is still in the ruined church; For the owls are out—and his light.
COMMON AND UNCOMMON SPONGES.
A FINE SPONGE.
They are all wonderful enough, no matter how common they may be. It takes thousands and thousands of minute creatures, to make a sponge, and these creatures are so little understood that about all we know of them is that they must belong to the very lowest order of
animal life, and that they do build sponges. That is not much to know, but it is not long since the sponge was first known to be an animal production at all, and our scientific men may yet find out something more definite about these curious little architects. Perhaps they may have lately found out something, and I have not heard of it. This would be the least wonderful thing about sponges.
The ordinary form of the sponge is familiar to nearly everybody who has ever been washed, and this picture gives a good idea of a fine large one, as it is found growing at the bottom of the sea. I say growing, because it seems to be growing there, like a vegetable. But it does not grow, in the ordinary sense of the word, any more than a wasp’s nest grows.
But there are sponges with which we are not at all familiar, and which are curious, apart from the manner of their construction. Such a one is the sponge called the “Cup of Neptune.”
This is several feet high, and is formed like a great goblet. It would make a very good cup for Neptune, if he drank brandy or rum, for it would soak up all that he poured into it, and he could not get a drop, unless he squeezed his cup pretty hard—and even then the liquor might all run out of the bottom.
As a rule, civilized and well educated people are more easily surprised and astonished at uncommon and wonderful works of nature than uncivilized or ignorant people, for the latter do not know enough to be astonished. They see nothing strange in the development of a plant from its seed—nothing grand in a high mountain, nor anything very beautiful in a flower. They look at these things as a child looks at his hand. The hand is a very curiously constructed instrument, full of intricate mechanism, but the child does not know or think of that. It is not until he grows older and his mind is cultured that he appreciates the wonderful construction and the varied action of his hand.
So it is with savages. They do not comprehend that many strange works of nature are worthy of admiration, and they take it for granted that things are as they are because they ought to be, just as they think of their own bodies, if they think of them at all.
THE CUP OF
But this great goblet-like sponge is strange enough to astonish even a savage.
NEPTUNE.
MAGHAR’S LEAP.
It chanced upon a time, a very great many years ago, while fairies and magicians still dwelt upon earth, that a youth and maiden— brother and sister—were walking in a forest, talking about their recent misfortunes, and laying plans for their future. The youth was clad in armor, according to the warlike fashion of those times. But he had under his arm a book, which was not in accordance with the fashion of those times. The maiden wore a dress of some coarse woolen stuff; and, in her hands she held a sheet of parchment, and a pen.
Suddenly there broke into their quiet talk the sound of clashing arms, and the mad plunging of horses. Sybil, the maiden, stopped terrified.
“Oh!” she cried, “it is the noise of battle! Too well I know those sounds. Let us go quickly back!”
“Let us go forward a little way,” said Maghar, the youth, “to yon opening in the woods. Or, stop here, if you fear, and I will go alone and look out.”
“No,” said Sybil, “if you go I will follow.”
Together they looked out upon the open plain. Two hostile armies had met unexpectedly, and a fierce conflict had commenced.
“Alas!” said Sybil, shuddering. “There are the savage infidels that laid waste our home!”
“Yes,” said Maghar, excitedly, “and here, on this side, are our countrymen, and neighbors! I must bear a hand in this fight!”
“And leave me alone!” cried Sybil. “I have only you left! Your single arm will not count for much in a battle!”
“It would be a shame to me,” said Maghar, “to sneak off, like a coward, and leave our friends and Christian soldiers, when their
forces are few, and every warrior counts. Have I not my armor? I shall find shield and spear on the battle-field on some poor fellow who has already fallen in the fray. Do not fear, sister! Go back to Christern’s cottage. There you will be safe; and I will return in a few hours.”
So saying, he led Sybil back into the forest to the path leading to Christern’s cottage; gave the book into her hands; and, kissing her good-bye, he ran out of the woods as fast as the weight of his armor would allow.
But Sybil did not return to the cottage. She was too anxious about her brother; and, going to the entrance of the wood, she crouched among the trees, where she was hidden from view, and watched the progress of the fight. She was ready to fly if the tide of battle brought the armies too near. But they seemed to be gradually moving away from her. She soon singled out her brother. He had secured a spear
SYBIL’S WATCH.
and shield, and mounted a riderless horse. In a few minutes he was lost in the throng, and she saw him no more.
Her mind was filled with sad forebodings. This Infidel army had invaded the country, and laid it waste; had killed her parents, and overthrown, and utterly ruined the beautiful castle that had been her home. A few things had been saved by old Christern, a much loved servant of the family, and these constituted the property of Maghar and Sybil. Old Christern’s cottage, in the depths of the forest, was the refuge of the orphans. There they had lived for several weeks, and no way of retrieving their fortunes seemed open to them. Maghar was a fine scholar. His father had had him taught to read his own language and Latin, and to write a very beautiful hand. That was the extent of his knowledge; and it was a great deal at a time when very few of the richest people knew their letters.
And now, in their poverty, there seemed to be very little use for his learning. Nobody cared anything about it. He might copy manuscript for some learned man, and get a living this way, for printing and paper had not then been invented; and all books were written on parchment. But Maghar had a contempt for a clerk, as he called a copyist, and did not fancy this method of supporting his sister and himself. Nevertheless, the two were that day on their way to the abode of a great and learned man to see if he wished anything of this kind done; and if he would buy their only book—a Latin volume, written on parchment, and beautifully illuminated and bound in wooden covers.
Sybil went over these things in her mind as she watched the battle, trying, in vain, to distinguish the form of her brother. She soon saw to her dismay, that the Infidel forces had turned the flank of the Christian army, and that the ranks of the latter were broken, and they were retreating, closely followed by their enemies. She stood up now, and strained her eyes to watch them until they had all disappeared over the crest of a hill. Then she sadly returned to Christern’s cottage to tell the old man of this new and terrible misfortune.
Days passed away, and Maghar did not return. Christern learned that the Christian army was broken, and the soldiers scattered. Some had returned to their homes. The wounded were cared for among their friends. The dead were buried. But Maghar was with none of these. No one could tell anything about him, except that he had fought bravely.
Then Sybil determined to seek out the great and learned man to whom Maghar had intended to offer his services as copyist. She was somewhat afraid of him, for he was known to be a powerful magician. But he could, no doubt, tell her the fate of Maghar, and she would try to overcome her fears.
She took off the coarse peasant’s dress she had been wearing, and arrayed herself in her best robe of fine white cashmere, which was one of the things that Christern had managed to save. She loosened her beautiful hair, which fell nearly to her feet. This last she did to show the deep sorrow she was in. She also took with her the Latin volume, as a present, to propitiate the powerful magician.
The great man lived in the simplest manner in a rocky cavern. Sybil found him outside his dwelling, seated on a mossy stone, sorting some plants that lay in his lap. He did not look up as she approached, and she had a good opportunity to study his countenance, which was so sweet and gentle that her fear of him vanished; and she came forward quite boldly, greeted him, and presented her book.
But the magician waved the volume aside. “I know why you seek me, sister of Maghar,” he said, kindly.
“Oh, can you tell me aught of my brother?” cried Sybil.
“I know not where he is. The oracles would not enlighten me without your presence. Come into my dwelling, and we will consult them.”
So saying he conducted her into his cave through a low, dark passage way. Great was Sybil’s astonishment when she found herself in a vast room, with a lofty ceiling. Around the circular walls was a continuous row of lamps, kept constantly burning. Their light
was reflected from myriads of stalactites that hung from the roof, glowing with all the colors of the rainbow, making the rough, rocky chamber as brilliant and gorgeous as a fairy palace. In the centre of the room stood a brazier, filled with burning coals, and near it, a large iron harp, with silver strings, and a sort of cupboard, made of iron. A few rough couches were scattered around. And this was all the furniture the room contained.
The magician invited Sybil to take a seat. He then proceeded to place on his head a crown, woven of vines of magical virtues. He took from the cupboard some singular-looking vessels, and mixed in them various powders and liquids. Then, pouring all their contents into a copper pot, he placed it on the coals, seated himself on a stone near it, drew his harp in front of him, and motioned to Sybil to stand before it. He looked so pleasantly upon her she did not feel afraid, but her heart beat fast, not knowing what fearful thing she might see.
She saw nothing whatever but the harp, and the old man; for, as soon as the clouds of fragrant white smoke that poured out from the brazier, had completely enveloped the two, the magician swept his fingers over his harp, and began to sing. Then Sybil forgot everything else, for his chant was of Maghar.
SYBIL AND THE MAGICIAN.
He sang of the great deeds Maghar had done in the battle, and how he had made himself famous. He was the last prisoner taken by the Infidels; and was now confined in a castle several leagues distant. The Infidel army was there encamped. They would like to slay Maghar outright, but were afraid of the vengeance of the Christian armies near them if they murdered a man held in such esteem. He was at present undisturbed, but the probability was that,
after a time, they would decide to starve him to death, and give out word that he had died from sickness. His sister had thus a little time in which to work to save him.
Here the song ended, and the weeping girl begged the great magician to save her brother. This he said was not in his power. She must find a good fairy, and make it her friend. The small creature could get into the castle, see her brother, and, together, they could devise a way of escape. He might, perhaps, be able to help them then. He told her what roads to follow to reach the castle; and, assuring her that such a good girl would surely find a good fairy to assist her in her trouble, he dismissed her with his blessing.
That very day Christern and Sybil set out for the castle. They reached the place after three days’ journey. They told no one what their errand was in that part of the country; and there were so many homeless people in the land that their appearance excited no surprise. Christern soon found employment among the wood-cutters, and fitted up a deserted hut as a temporary dwelling.
But though they could, every day, look upon the walls of the castle in which Maghar was confined, they seemed no nearer to him than before. He was in the hands of the cruel infidels, and where were there any fairies? There were plenty in that part of the country, the wood-cutters said, which, at first, was encouraging. But, on inquiry, it turned out that not one of them had ever seen a fairy, or knew anybody who ever had seen one. Sybil was in despair as the days went by, and she blamed her friend, the magician, that he had given her no help, after all.
She often walked through the woods, near nightfall, to meet Christern. One evening, as the two were returning together to their hut, they saw a large wild boar approaching, followed by several young ones. As this creature is very savage when it has its young to defend, Christern and Sybil thought it wise to step aside among the trees, and leave the path to the boar and its interesting family After these had passed they continued their way, but had not gone far when they saw a young boar lying in the path. Christern stooped over to examine it.
THE BOAR FAMILY.
“It got in with that litter,” said he, “and did not belong to it, so the old boar has gored it badly. But it is not dead. I’ll take it home, make a sty for it, and, if it lives, I’ll fatten it, and kill it when it is fit for eating.”
The wounded animal lifted an appealing glance to Sybil. Its eyes wore an almost human expression of suffering, and a most beseeching plea for help. The girl’s heart was touched.
“It is not badly hurt,” she said. “Its flesh is torn, but if I wash its wounds, and bind them up, and find a nice place in the woods, where I can make it comfortable, and feed it, it will get well. It is a free, wild creature, and must not be shut up in a close sty. Think of my dear brother shut up when he wants to be free!”
Christern thought Sybil’s plan a foolish one, but this last argument silenced him. He had not a word to say in reply. So the girl washed
off the blood from the boar’s wounds with her fine cambric handkerchief, which she then tore into strips to bind them up. She found, in a secluded place, a soft cushion of moss on which she laid him, and partly covered him with leaves to keep him warm. She then brought from the hut some of her own scanty supper, and gave it to the little boar.
After this she visited her patient two or three times a day, nursing and feeding him. But, on the afternoon of the fourth day, he had disappeared, and Sybil returned to the hut feeling quite lonely at the loss of the little creature that had been so glad to see her.
The next night, as Christern was returning late from his work, trudging slowly through the forest, with his lantern swinging in his hand, and his wallet slung over his back on the end of his walking stick, something brushed close by the old man’s ear with a buzzing of tiny wings.
“That dragon-fly is out late,” said the old man to himself.
Very soon the wings brushed by him again with a louder whizzing.
“It is a bat!” said the old man, shaking his head. “Shoo! shoo!” But the third time the whirring wings flew almost into his face.
“Good evening, old Christern!” said a tiny voice, such as might come from a humming-bird, if it could speak.
The startled old man stopped and flashed the light of his lantern around among the trees. And there, with wee wings outspread, was a fairy skimming through the air! Christern had never seen a fairy, but he knew this was one as soon as he saw him. And a jolly, rollicking fellow he was!
CHRISTERN AND THE FAIRY.
“You don’t know me, old fellow?” said the fairy.
Christern shook his head.
“Wanted to shut me up in a sty, and fatten me, eh? I wouldn’t be much of a mouthful now, would I? Don’t you wish you could get me?”
And the saucy fellow soared high up among the trees.
Christern nearly dropped his lantern in his astonishment. “You don’t ever mean to tell me that boars are fairies?” he said, at last.
“I mean to say nothing of the kind!” cried the fairy, indignantly. “Your horrid, beastly boars are no relations of ours, even! I’ll tell you how it was,” he said, coming nearer Christern, and speaking in a confidential tone. “Our fairies all have wings, and can fly, but there are other kinds without wings. Some of these are good, but some are bad, and they are full of spite against us because we are better off
than they I offended a tribe of these not long ago, and they had influence with a wicked old witch who changed me into a little boar. I was to remain in that shape for a week. She would have made the time longer, if she could. But they all thought I would be killed in that time. And so I should have been but for your Sybil. And there was another thing worse than death. If I was deprived of my liberty during that week, I could never again regain my natural shape. So, if you had put me in your sty, I would have been eaten up one of these days as a boar. From this awful fate your Sybil saved me. So I am doubly indebted to her, and I want to do something for her.”
“Oh, you are the good fairy, who is to save our Maghar!” cried the old man, joyfully.
Thereupon he related the whole sad story, and the fairy told him he would consult with his tribe that night; and, if he and Sybil would come to that spot on the following night he would let them know what could be done.
Sybil’s delight was unbounded. She now felt sure that her brother would be saved. But, nevertheless she accompanied Christern to the place of meeting, half fearing that the frisky fairy would play her some trick. But he was there, before them, and had dressed himself in his best suit of green in honor of the occasion.
As soon as they appeared he began chattering as fast as ever he could.
“We fairies have hit upon a splendid plan,” he said. “But there is no time to lose. Sybil, I have seen your brother, but he did not see me. I was at the castle this morning before cock-crow. I flew in through a loop-hole. Nobody saw me. It took me a long time to find out in what room your brother was kept, but, at last, I made it out. I intended to stay until I did. He is in a room, high up in the north tower. He has been pretty well, but now his jailers have begun the plan of starving him; and he will soon be too weak to save himself as we propose, which is the only way open to him. It requires steady nerves, and great courage. But do not weep, for we will save him, only it must be done speedily. Do you, Christern, be ready to go with me to the castle at break of day. Pretend you are a beggar. There are so many
of these you will pass unsuspected. I will point out to you a small postern door at the back of the castle, stay about that; and I will hide near it. I could slip inside easily enough, and tell Maghar what to do, but he does not know me, and would not trust me. So you must get inside the castle some way and see him. And, not only that, but you must get out again. And this is our plan for doing this. We fairies have three magical cocks. At a signal from me these cocks will appear on the crest of the hill at the back of the castle, and will sing a song. This will so astonish the sentinels that they will be thrown off their guard. I will then slip in through a loop-hole, unlock the postern door, and let you in. We will tell Maghar how he can escape. Then the cocks will appear again, and while the attention of the guards is distracted, we will get out of the castle. Remember now to be here at daybreak.”
And the fairy disappeared, much to Sybil’s regret, who had a hundred questions to ask him about her brother’s appearance, and treatment. He had not even told her what his plan was for her brother’s escape. But he did not come back, and she was obliged to be satisfied with the information she had.
The programme was carried out in every particular. Christern acted his part of beggar so well that he managed to get near the postern door, unsuspected, with the fairy snugly tucked into a fold of his ragged dress. On arriving at the place the fairy concealed himself in some vines. At the appointed signal three magnificent cocks appeared abreast on the top of the hill.
THREE MAGICAL COCKS.
The like of these cocks had never been seen in that country, and they immediately attracted the attention of everybody. But when they opened their mouths, and began to sing the words of a war song, the sentinels forgot everything, and deserted their posts to get as near the wonderful songsters as possible without alarming them.