The book addresses distributed optimization and viral spreading in multi-agent systems by providing theoretical foundations and practical implementations. For distributed optimization, it covers consensus, coverage, and formation control algorithms, and applies them to distributed optimization problems. It also discusses distributed subgradient algorithms and ADMM for distributed optimization, with Python code examples to illustrate the concepts. Regarding viral spreading, the book introduces mathematical models like SI, SIS, and SIR, and analyzes the spread of viruses over complex networks, including random networks and scale-free networks. It uses Python simulations to demonstrate the dynamics of viral spreading, offering insights into the impact of network structure and individual behavior on the spread of diseases.