diff --git a/pretext/AlgorithmAnalysis/BigONotation.ptx b/pretext/AlgorithmAnalysis/BigONotation.ptx index 8fb0afc..067f1a5 100755 --- a/pretext/AlgorithmAnalysis/BigONotation.ptx +++ b/pretext/AlgorithmAnalysis/BigONotation.ptx @@ -199,7 +199,7 @@ another.

Figure 1: Common Big-O Functions - + Graph of common Big-O functions (constant, logarithmic, linear, n log n, quadratic, cubic, exponential) showing their comparative growth rates as n increases.
@@ -252,7 +252,7 @@ main() ignored as n grows larger.

Figure 2: Comparing T(n) with Big-O Functions - + Graph comparing a specific T(n) function (3n^2+2n+4) with Big-O functions like O(n^2) and O(n^3), illustrating how T(n) follows the O(n^2) curve as n increases.

shows a few of the common Big-O functions as they compare with the T(n) function discussed above. Note that diff --git a/pretext/AlgorithmAnalysis/WhatIsAlgorithmAnalysis.ptx b/pretext/AlgorithmAnalysis/WhatIsAlgorithmAnalysis.ptx index d05e590..4ead1b2 100755 --- a/pretext/AlgorithmAnalysis/WhatIsAlgorithmAnalysis.ptx +++ b/pretext/AlgorithmAnalysis/WhatIsAlgorithmAnalysis.ptx @@ -237,7 +237,7 @@ main() following 8 \times 9.rectangle.

Figure 1: Sum of n = 8 integers - + Diagram illustrating the sum of the first 8 integers as a blue area within an 8x9 rectangle. The blue area represents 1+2+3+4+5+6+7+8 squares.

To find the blue area, we can count the number of blue squares 1+2+3+4+5+6+7+8, which we just learned diff --git a/pretext/ComplexityScience/DifferentModelsForDifferentPurposes.ptx b/pretext/ComplexityScience/DifferentModelsForDifferentPurposes.ptx index 1a6065b..bb4b971 100755 --- a/pretext/ComplexityScience/DifferentModelsForDifferentPurposes.ptx +++ b/pretext/ComplexityScience/DifferentModelsForDifferentPurposes.ptx @@ -15,7 +15,7 @@

Reductionism is the view that the behavior of a system can be explained by understanding its components. For example, the periodic table of the elements is a triumph of reductionism, because it explains the chemical behavior of elements with a model of electrons in atoms. Holism is the view that some phenomena that appear at the system level do not exist at the level of components, and cannot be explained in component-level terms.

We get back to explanatory models in , instrumentalism in , and holism in

- +

Q-1: Classical models are better to

@@ -39,7 +39,7 @@
- +

Q-2: Complex Models are better to

diff --git a/pretext/Graphs/Generating.ptx b/pretext/Graphs/Generating.ptx index ddb7d21..5958f2e 100755 --- a/pretext/Graphs/Generating.ptx +++ b/pretext/Graphs/Generating.ptx @@ -3,7 +3,11 @@ Generating Graphs
A complete graph with 10 nodes. - " A complete graph with 10 nodes." + + Complete graph with 10 nodes. + +

The image depicts a complete graph consisting of ten nodes. These nodes, labeled 0 through 9, are arranged in a circular pattern for visual clarity. Every node is connected to every other node by a straight edge, forming a dense network where all possible connections are present. This illustrates the fundamental property of a complete graph: full interconnectivity between all its vertices.

+

We'll start by generating a complete graph, which is a graph where every node is connected to every other.

Here's a generator function that takes a list of nodes and enumerates all distinct pairs. If you are not familiar with generator functions.

diff --git a/pretext/Graphs/GeneratingER.ptx b/pretext/Graphs/GeneratingER.ptx index 8c9d68e..3705a52 100755 --- a/pretext/Graphs/GeneratingER.ptx +++ b/pretext/Graphs/GeneratingER.ptx @@ -3,7 +3,12 @@ Generating ER Graphs
An ER graph with n=10 and p=0.3. - " An ER graph with n=10 and p=0.3." + +Visual representation of an Erdős-Rényi random graph with 10 nodes and specific edge connections based on p=0.3. + +

The image displays an Erdős-Rényi (ER) random graph. It features 10 circular nodes, which are labeled with integers from 0 to 9. These nodes are arranged in a somewhat irregular, non-grid layout across the viewing area.

+

Edges, represented as lines, connect various pairs of these nodes. The graph is not complete, meaning not all possible pairs of nodes are connected. This visual sparsity is characteristic of an ER graph where edges form with a probability p (in this case, p=0.3 for n=10 nodes). For instance, the visual details show that node 3 is connected only to node 2, while other nodes, such as node 7, exhibit multiple connections to different nodes within the graph.

+

The ER graph G(n, p) contains n nodes, and each pair of nodes is connected by an edge with probability p. Generating an ER graph is similar to generating a complete graph.

The following generator function enumerates all possible edges and chooses which ones should be added to the graph:

diff --git a/pretext/Graphs/NetworkX.ptx b/pretext/Graphs/NetworkX.ptx index ed13ba2..c8c6a5d 100755 --- a/pretext/Graphs/NetworkX.ptx +++ b/pretext/Graphs/NetworkX.ptx @@ -3,7 +3,13 @@ NetworkX
An undirected graph that represents driving time between cities. - " An undirected graph that represents driving time between cities." + + Undirected graph: driving times for Albany, Boston, NYC, Philly. + +

The image displays an undirected graph representing a road network with driving times. It features four square-shaped nodes, labeled with city names: Albany, Boston, NYC (New York City), and Philly (Philadelphia), positioned to roughly approximate their geographical locations.

+

Edges, as lines, connect these cities, indicating direct driving routes. Each edge is labeled with the driving time in hours. Specifically, the connections are: Albany to Boston (3 hours), Albany to NYC (4 hours), Boston to NYC (4 hours), and NYC to Philly (2 hours).

+
+

To represent graphs, we'll use a package called NetworkX, which is the most commonly used network library in Python.

We can create a directed graph by importing NetworkX (usually imported as nx) and instantiating nx.DiGraph:

diff --git a/pretext/Graphs/ProbabilityOfConnectivity.ptx b/pretext/Graphs/ProbabilityOfConnectivity.ptx index 2764c6c..84feb32 100755 --- a/pretext/Graphs/ProbabilityOfConnectivity.ptx +++ b/pretext/Graphs/ProbabilityOfConnectivity.ptx @@ -3,11 +3,21 @@ Probability of Connectivity
Probability of connectivity with n=10 and a range of p. The vertical line shows the predicted critical value. - " Probability of connectivity with n=10 and a range of p. The vertical line shows the predicted critical value" + + Line graph: probability of connectivity (n=10) vs. probability of edge (p). + +

The graph plots the probability of graph connectivity against the probability of an edge (p) for a graph with n=10 nodes. The x-axis, labeled 'Prob of edge (p)', is on a logarithmic scale ranging from 10^{-2.5} to 10^0=1. The y-axis, labeled 'Prob connected', ranges linearly from 0.0 to 1.0. A blue S-shaped curve illustrates the relationship, showing the probability of connectivity rising from near 0 to near 1. The steepest part of this ascent occurs around p \approx 0.23. A vertical gray line at this x-value indicates the predicted critical value for p.

+
Probability of connectivity for several values of n and a range of p. - " Probability of connectivity for several values of n and a range of p." + + Connectivity probability vs. edge probability (p) for n=30, 100, 300. + +

This line graph shows how graph connectivity probability changes with varying numbers of nodes (n) and edge probability (p). The x-axis, 'Prob of edge (p)', is logarithmic (10^{-2.5} to 10^0). The y-axis, 'Prob connected', ranges from 0.0 to 1.0.

+

Three S-shaped curves are shown: a dark blue curve for n=30, a medium blue curve for n=100, and a light blue curve for n=300. Each curve has a faint vertical line at its critical point for p.

+

As n increases, the S-curve (transition to connectivity) shifts left towards lower p values and becomes steeper, indicating a more abrupt transition.

+

For given values of n and p, we would like to know the probability that G(n, p) is connected. We can estimate it by generating a large number of random graphs and counting how many are connected. Here's how:

def prob_connected(n, p, iters=100):
diff --git a/pretext/Graphs/SelfCheck.ptx b/pretext/Graphs/SelfCheck.ptx
index ea36347..f57421d 100755
--- a/pretext/Graphs/SelfCheck.ptx
+++ b/pretext/Graphs/SelfCheck.ptx
@@ -3,7 +3,13 @@
   Self Check
   
A Graphical represention of a Friend Network - "Graph of Friend Network" + + Graph of Friend Network + +

An undirected graph depicts a social network with five nodes: Josh, Kate, Jerry, Mary, and Billy-Bob. Edges show connections between these individuals.

+

Josh is connected to Billy-Bob. Kate is connected to Jerry, Mary, and Billy-Bob. Jerry is connected to Kate and Billy-Bob; Mary is also connected to Kate and Billy-Bob. Billy-Bob connects to Josh, Kate, Jerry, and Mary, acting as a central connector.

+

The connections are mutual, indicating friendships or bidirectional relationships.

+
diff --git a/pretext/Graphs/WhatIsAGraph.ptx b/pretext/Graphs/WhatIsAGraph.ptx index 698af8f..e209768 100755 --- a/pretext/Graphs/WhatIsAGraph.ptx +++ b/pretext/Graphs/WhatIsAGraph.ptx @@ -3,7 +3,14 @@ What is a Graph?
A directed graph that represents a social network. - " A directed graph that represents a social network." + + Directed three-node graph showing social network connections. + +

The image displays a simple directed graph with three nodes, visually representing network elements. Edges, as arrows, show the direction of relationships. The nodes can be identified as Alice, Bob, and Chuck based on the text's example.

+

A mutual, bidirectional connection exists between two nodes (Alice and Bob), shown by arrows pointing from each to the other. Both of these nodes also have outgoing arrows directed towards the third node (Chuck).

+

The third node (Chuck) only has incoming arrows from Alice and Bob and no outgoing arrows. This structure illustrates the example where Alice and Bob follow each other, both follow Chuck, and Chuck follows no one back.

+
+

To most people a graph is a visual representation of data, like a bar chart or a plot of stock prices over time. That's not what this chapter is about.

In this chapter, a graph is a representation of a system that contains discrete, interconnected elements. The elements are represented by nodes — also called vertices – and the interconnections are represented by edges.