Fei YUN
xxx-xxx-xxxx
address:xxxxx
Yuhe YUAN
xxx-xxx-xxxx
address:xxxxx
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
the charitable organization (often called the receiver) and the person or entity donating (often call the donor). The charitable organization must keep accurate records of donations received, but so must the donor keep records of the donations they have given.


--- layout: archive title: Zulip Chat Archive permalink: /stream/113488-general/topic/simp.20lemmas.html ---
Can someone explain to me why set_of_eq_eq_singleton is not a simp lemma it seems like a decent candidate to me, or indeed if it should be?
Same question for list.pairwise.nil !
set_of_eq_eq_singleton
seems like a good candidate for a simp
-lemma. You will notice that not everything is properly marked as a simp lemma. Feel free to make a PR.
We don't usually mark non-equalities, like list.pairwise.nil
as a simp-lemma. I don't think that simp
solves things like (0 : nat) <= n
. list.pairwise.nil
might be an exception, though: searching through mathlib, it's used quite frequently in simp
.
Will do. Okay succ_pos was what I was thinking of also w.r.t. non-equality, but it seems like such lemmas marked simp are rare.
I don't see any reason to limit simp
to equations. In Isabelle, simp
is often used to prove simple facts. Here is an example:
import data.nat.prime open nat attribute [simp] nat.prime.ge_two example (p : nat) (h : prime p) : p ≥ 2 := by simp *
Better examples are that abs (x^2)
and abs (exp x)
should simplify tox^2
and exp x
, respectively, because the simplifier can show that these are nonnegative. In Isabelle, the simplifier is really good at proving theorems of the form finite t
, where t
is a subset of an arbitrary type, and this is really useful for conditional rewrites with sums and products. (It will also call linarith
to dispel side conditions, which means that it can simplify abs(x^2 + exp x + 7)
.)
By the way, library_search
fails on the example above because of the annoying issue with >= and <=. We should probably get in the habit of expressing all our theorems in the <= form, in which case library_search
works.
import data.nat.prime open nat @[simp] theorem nat.prime.two_le (p : nat) (h : prime p) : 2 ≤ p := nat.prime.ge_two h example (p : nat) (h : prime p) : p ≥ 2 := by library_search
But this doesn't replace the utility of using simp
to do similar things. The point is that simp
is a conditional simplifier, and so it is useful if it can show p ≥ 2
when it is simplifying something like p - 2 + 2
on nat
.
Last updated: Apr 24 2020 at 19:02 UTC


Pot stocks surge for a second day after a marijuana legalization act passes a key vote
by Carmen Reinicke- On Wednesday, the Marijuana Opportunity Reinvestment and Expungement (MORE) Act passed a key vote by the House Judiciary Committee.
- Cannabis company stocks surged Wednesday and extended gains into Thursday on the news.
- Although the MORE Act’s fate is uncertain, “companies that support the industry are thrilled to see it advance,” said Ben Curren of Green Bits, which makes compliance software for cannabis companies.
- Read more on Business Insider.
Cannabis company stocks extended soaring gains into a second day Thursday after a key marijuana legalization bill was passed by the House Judiciary Committee a day earlier.
The committee approved the Marijuana Opportunity Reinvestment and Expungement (MORE) Act Wednesday morning in Washington, D.C., voting 24-10 in favour of the bill. Cannabis stocks surged on the news.
The vote is important for the cannabis industry because the MORE Act would decriminalize and deschedule marijuana. That means marijuana would be removed from the schedule 1 drug list of controlled substances in the US, and that some cannabis offences would be expunged.
The act would “allow the sector to take a giant leap forward,” said Ben Curren, founder of Green Bits, which provides compliance software to cannabis companies, in an email to Markets Insider. Although its fate going forward is uncertain, “companies that support the industry are thrilled to see it advance,” he said.
Here’s how much six popular cannabis companies gained Thursday, from highest to lowest jump in share price:
- Hexo: +41%
- Aurora Cannabis: +22.7%
- Canopy Growth Corp: +21.6%
- Cronos: +16.4%
- Curaleaf: +14%
- Tilray: +13.5%
Next, the bill will go to the House for a vote, where it’s widely expected to be supported by the Democratic majority. It faces tougher scrutiny in the Republican-controlled Senate, especially as Majority Leader Mitch McConnell is firmly against legalizing marijuana, though he’s supported legalizing hemp.
While the MORE Act passing the key vote is a good thing for the cannabis industry, the road ahead to legalization in the US is far from certain, according to W. Andrew Carter of Stifel.
“We believe this has a very low probability of success,” Carter wrote, even though the “legislation’s momentum underscores our robust long-term outlook for the global cannabis industry.”
The multiple-day gains come after a rough week for cannabis companies, where disappointing earnings sent shares tumbling.
While many pot stocks are still a far cry from an all-time high, the rebound is positive. For example, Canopy Growth is still down roughly 66% from its year-to-date high in April through Wednesday’s close, but there’s evidence that the “worst is over,” according to a Wednesday note from Bank of America Merrill Lynch.


Requirements
Functional Requirements
The following are the functional requirements for the system:
- FR-1. The application shall allow caregivers and patients to register an account.
- FR-2. The application shall provide a user interface to allow its user to access their metrics and update their personal information.
- FR-3. The application shall enable notifications to be sent to the requested parties.
- FR-4. The application shall interface with various technologies such as wearable technologies, mobile phones, and desktop computers.
- FR-5. The application shall allow direct communication between the doctor and caregiver.
- FR-6 The application shall warn the caregiver and doctor if the patient's blood oxygen decreases rapidly.
- FR-7 The application shall warn the caregiver and doctor if there are any medical anomalies.
- FR-8. The application shall support patients' and caregivers' ability to create appointment reminders and alerts for a wide range of medical issues and tasks.
- FR-9. The application shall support external fingerprint scanning for extra security.
- FR-10. The application shall have a backup way to sign in and out in case of a fingerprint scanner error.
- FR-11. The application shall exist between different mobile operating systems such as iOS and Android.
- FR-12. The application shall provide geolocation to help find a patient in case of an emergency.
- FR-13. The application shall allow bidirectional synchronous communication between the user and the data source in real-time.
Non-Functional Requirements
These Non-Functional requirements impose constraints under which the application we are developing has to function. The following are the requirements that we are explicitly defining and hold for each customer instance.
Architecture:
- NFR-1. Allow for disparate data sources to be ingested in a multi-tenant and performant manner. (Apache Kafka or Kinesis streams)
- NFR-2. Multiple location cloud production environments.
- NFR-3. Containerized services for quick swapping/ability for hybrid strategy in the future.
- NFR-4. Web and mobile endpoints that help collect and analyze data, multi-role users.
Security:
- NFR-5. The application must comply with HIPAA regulations.
- NFR-6. Only run on specific versions of devices for security reasons.
- NFR-7. Data storage must conform to HIPAA and FEDRAMP requirements.
Safety:
- NFR-8. Data from the database will never be transmitted to unauthenticated sources.
- NFR-9. The application will never disclose patient information to users that are not authorized to see it.
Availability:
- NFR-10. The application should be available 99.99% of the time.
Performance:
- NFR-11. The application shall take no more than 2 seconds to access.
- NFR-12. The application's fingerprint scanning shall recognize registered users 95% of the time.
- NFR-13. The application shall take the appropriate measures to ensure data servers are secured.
- NFR-14. Data backups should be created daily (minimum).
- NFR-15. Data backups should be securely stored separately.
- NFR-16. A private REST API should be available for third-party, desktop, or mobile application integration.
- NFR-17. The access to all data should take a least privilege approach.
- NFR-18. Data streaming should be processed near real-time.
- NFR-19. The application shall have the ability to change out algorithms for smart altering.


Translate HTML code to Vue, React or Angular.
## Instalation
To install simply: Use npm
```sh
npm i -g rocket-translator
```
or Yarn
```sh
yarn global add rocket-translator
```
## Getting Started
### Basic
You can convert this:
```html
Hello {name - state - "World"}!
```
into this:
```jsx
import React, {Component} from "react";
class MyComponent extends Component {
constructor() {
super();
this.state = {
name:"World"
};
}
render(){
return(
Hello {this.state.name}!
)
}
}
export default MyComponent;
```
or this:
```html
Hello {{name}}!
```
Or this:
```ts
import { Component } from '@angular/core';
@Component({
selector: 'test-root',
template:`
Hello {{name}}!
`
})
export class Test {
name = "World";
}
```
### How to Use
To use, simpy create a HTML file, with the code to translate, and run:
```sh
rocket [mode] path/to/file.html [output folder]
```
The **mode** may be `vue`, `react` or `angular`.
The **output folder** is optional, if this is not defined will create a folder named **dist**.
## Guide
* [States Simple](#states-simple)
* [Props](#props)
* [Computed](#computed)
* [Methods](#methods)
* [Components](#components)
* [Watchers](#watchers)
* [Inputs Handler](#inputs)
* [Conditionals](#conditionals)
* [List Render](#loops)
* [Bind Attributes](#binds)
* [JavaScript Management](#js-management)
* [HTML Syntax](#syntax)
### States Simple
A **State** in a Vue or React component, are a way to set data that affect the view, and when this changes, the component re-render the view.
To get values from the HTML, we must declare into `{}`. And to the declare a state, we have 2 modes to set it: **Simple**, **With Value**.
The **Simple** mode, is declared writing only the state name into the template and writing the type: **state**.
Example:
```html
{myState - state}
```
In the **With Value** mode, is declared when, we write the state name, the type: **state** and the value for this state.
Example:
```html
{stateName - state - "Some Value"}
```
The **value** may be `String`, `Number`, `Boolean`,`Array` and `Object`.
And in the **simple** case, we obtain the next component state.
In Vue:
```js
data(){
return {
myState:""
}
}
```
In React we obtain:
```js
this.state = {
myState:""
}
```
And in Angular:
```ts
export class Test {
myState = "";
}
```
In the **With value** case we obtain. In Vue:
```js
data(){
return {
stateName:"Some Value"
}
}
```
On React:
```js
this.state = {
stateName:"Some Value"
}
```
And on Angular:
```ts
export class Test {
stateName = "Some Value";
}
```
Since version `2.0.0` you can add a prop in a bind attribute with the same format that in the bars expression `stateName - state`;
Example:
```html
Hello World!!!
```
Or you can add the value next the `state` word.
```html
Hello World!!!
```
To know more about states and JavaScript Management. You can see [JavaScript Management](#js-management) section.
### Props
The **props** in a component, are data that a parent \(**container**\) component pass to a child component.
And like the **state**, we may declare a prop with this format `{propName - prop}`.
Example:
```html
{parentData - prop}
```
And declaring a prop, the final template will render, in Vue:
```js
props:{
parentData:{
type:String,
required:true,
default:"Hello World"
}
}
```
And in React, auto declares the prop.
```js
return(
{this.props.parentData}
)
```
And on Angular, Import `Input` from `"@angular/core"` and declare as prop.
```ts
import { Component, Input} from '@angular/core';
...
export class Test {
@Input() parentData : string;
}
```
Since version `2.0.0` you can add a prop in a bind attribute with the same format that in the bars expression `propName - prop`;
Example:
```html
Hello World
```
### Computed
A **Computed** propierty is a function that return a `String` or `Number` value, and this is render on the template. And to declare a computed propierty, simply we can set the computed propierty name and the type: **computed** and create the function to execute that match with the computed name.
```html
{hello - computed}
```
```js
function hello() {
return "Hello World";
}
```
This will create a computed properties that returns a **Hello World**.
Example:
```html
Hi I Am {fullName - computed}!
```
Too know more about JavaScript Management go to [JavaScript Management](#js-management) section.
### Methods
A **Method** is a function executed by an event on the final render or by the render. Is not necesary declare the method only set the event into the tag.
```html
```
### Components \(**Partial**\)
To import a **component** inside the main component. Only add the tag with the component syntax.
```html
```
And to add a attr with a state value add `:` on the attr front.
```html
```
To write the component content, add a `component` tag with the **component content**. And add the attr `component-name` with the **component name**. And others attrs can be passed to the component.
```html
Hello {name - prop}!
```
### State Watchers
To define a **State Watcher** you must create the function `setStateWatchers` this function must return all the states watchers.
```js
function setStateWatchers() {
return {
state(e) {
//Handle State
},
anotherState: function(e) {
//Handle Another State
}
}
}
```
Also you can define as a `var`, `let` or `const`.
```js
const setStateWatchers = () => {
return {
//Watchers
}
}
```
### Inputs Handler
To **handle** a input, you must add the attr `name` on the input tag, and the value will be take to add a state with that name.
```html
```
On **Vue** will render.
```html
```
On React.
```jsx
import React, {Component} from "react";
class MyComponent extends Component {
constructor() {
super();
this.state = {
username:""
}
}
inputHandler({target}){
const value = target.type === 'checkbox' ? target.checked : target.value;
const name = target.name;
this.setState({
[name]: value
})
}
}
```
Do not implement on Angular. We will add this features in futures versions.
### Conditionals
To declare a **conditional**, add the `if` tag, with the `cond` attr, where `cond` is the condition to evaluate.
Example:
```html
Congratulations! you are Sign in this platform
```
And you can set it with an `else` tag.
```html
Password must have more of 6 charactersPassword is very strong
```
Since version **2.0.0** we add the `else-if` tag. Like the `if` tag, this take the attr `cond` with the condition.
```html
Too YoungToo Old
```
And now you can add the `tag` attribute to set conditional **tag name**.
Example:
```html
I must buy {item}
```
The `for` tag now will be a `li` tag.
**Vue**
```html
I must buy {{item}}
```
**Angular**
```html
I must buy {{item}}
```
On **React** put the content inside the **tag**.
```jsx
var loop_0000 = this.state.buyList.map(item =>
(
{item}
)
);
```
The default tag on **Vue** is the `template` tag.
On **React** don't have default tag. Put the content without tag.
And on **Angular** the default tag is the `div` tag.
### List Render
Like the conditionals, add a loop is't very easy, add a `for` tag, with the `val` attr.
```html
{varName}
```
And since the version `2.0.0` you can add the `tag` attribute to define the tag to put the loop content.
Example:
```html
I must buy {item}
```
The `for` tag now will be a `li` tag.
**Vue**
```html
I must buy {{item}}
```
**Angular**
```html
I must buy {{item}}
```
On **React** put the content inside the **tag**.
```jsx
var loop_0000 = this.state.buyList.map(item =>
(
{item}
)
);
```
The default tag on **Vue** is the `template` tag.
On **React** don't have default tag. Put the content without tag.
And on **Angular** the default tag is the `div` tag.
### Bind Attributes
A **Bind Attribute** is a form to set a state value on a tag attribute. And the syntax is like on Vue.
If you want add a default value you must add a `-` followed of the type.
```html
```
The type can be `state` or `prop`.
And with the type `state` you can add the `String` value next `state` word.
```html
```
### JavaScript Management
To the JavaScript Management, we add a few of keywords to help with the code imports. We must follow some rules to the correctly function of the translator.
To include JavaScript on the template, add a `script` tag with the JavaScript code to translate. Or you can add the line `#js path/to/js.js` to import a external file.
#### Lifecycles
Since version `2.0.0` we add supports for framework **lifecycle**; and like methods and computed, all lifecycles will be filtered.
We add 8 lifecycles to define the final component.
* **setInitialState**
* **setStateWatchers**
* **beforeMount**
* **mounted**
* **beforeUpdate**
* **updated**
* **beforeUnmount**
* **unmounted**
##### Set Initial States
`setInitialState` have the same function that the `state` keyword in previous versions, this define **states** that will not be rendered on template.
Example:
```html
Hi I Am: {fullName - computed}
```
##### Set State Watchers
`setStateWatchers` have the same function that the `watch` keyword in previous versions, this define all the states **watchers**.
Example:
```html
You have do {clicks - state - 0} clicks
```
#### Functions
The **Functions** are to change the method and computed properties execution. If the method or computed name match with the function name, this will be that method or computed.
```html
This is my {computedPropierty - computed} propierty
```
#### Filter
The **JavaScript Filter** is structured to filter the states and props. If into the code we have a function that contain a var with the state or prop name, this will be replaced automaticaly. Is not necesary declare like a state.
```js
function setInitialState() {
return {
name: "Hello",
lastName: "World"
}
}
function sayHello() {
alert(name + " " + lastName);
/*
will return on React: alert(this.state.name + " " + this.state.lastName);
and on Vue: alert(this.name + " " + this.lastName);
*/
}
```
**Note**: You must evite use vars with state names, until we fix this.
### HTML Syntax
Like on JavaScript, on HTML we have a specific **syntax**, that we must follow to the correctly translator function.
#### Bars Declaration
The most used is the **bars declaration** `{}`, this is used to assign a state, prop, computed or the out framework syntax.
Framework Declarative Syntax: `{ name }`
State without value: `{stateName - state}`
State With Value: `{stateName - state - value}`
The `value` can be type: `String`, `Number`, `Boolean`, `Array`, `Object`, `null`, `undefined`, `NaN` or `Infinity`.
Prop: `{propName - prop}`
Computed Propierty: `{computedName - computed}`
#### Import Tag
To import a JavaScript external file, we use: `#js path/to/js.js`.
**Note**: We want add **CSS** Support.
#### Bind Attributes
To execute JavaScript syntax or assign a state or prop value on an HTML attribute, we use `:attrName="Js or State"`.
#### Conditionals And Loops Tags
We add three HTML tags to assign **Conditionals** and **Loops**. `if`, `else-if`, `else` and `for`.
```html
If ContentElse If ContentElse ContentFor Content
```
#### Component Tag
We add this tag to declare a **custom** component inside the **Main Component**
```html
Component Content
```
## To Do
### Features Support
- [x] States
- [x] Methods
- [x] Computed
- [x] Props
- [x] States Watchers
- [x] Components
- [x] Bind States, Props, JS Expresions
- [x] Input Handlers
- [x] JavaScript Management \(**partial**\)
- [x] Conditionals
- [ ] Nested Conditionals
- [x] Loops
- [ ] Nested Loops
- [ ] Inner HTML
- [x] Lifecycles
- [ ] React without JSX
- [ ] React without ES6
- [ ] Vue Standalone
- [ ] Next Framework
- [x] Angular 7 Support
- [ ] Previous Angular Versions
**Note:** If you see that some feature is missing, you can open a pull request or write an issue, and tell what feature is missing.
## Contributing
To contribute you can open a **pull request** with the changes to improve in the code, or open a new **issue**.


---
layout: post
title: 3/30 schoolwork
date: '2014-04-01T20:41:00.002-06:00'
author: April
tags:
- homeschool-journal
modified_time: '2014-04-01T20:41:50.369-06:00'
thumb: https://lh4.googleusercontent.com/--zlbgjy4ETs/Uzo_QMwJy5I/AAAAAAAAbZQ/kHuUO-R-xNc/s72-c/blogger-image-325300729.jpg
blogger_id: tag:blogger.com,1999:blog-6400085873105072120.post-8987716406027490436
blogger_orig_url: http://www.svlark.com/2014/04/330-schoolwork.html
---
History


You'll be able to join and create events.
Requirements: At least 8 characters, at least 1 capital letter, at least 1 number.
Forgot your password?
Enter your email address and we'll send a reset link.
Please make the event begin in the future.
Please make the event end after it begins.


Career Profile
Click to View My Curriculum Vitae [PDF].
I am a member of ACM honored Class, an elite CS program for top 5% talented students. My reserch interests lie in Machine Learning, especially Reinforcement Learning and Deep Learning.
I plan to apply for CS PhD programs that starts in Fall 2020.
Experiences
- Advised by Prof. Weinan Zhang and Prof. Yong Yu.
- Focusing in reinforcement learning method for multi-agent.
- In charge of a course project, which is to develop a shooting game in C++
- Gave some lectures and prepared assignments and exams.
Projects
My projects here.
Mx Compiler
- A responsive website template designed to help startups promote, market and sell their products.


List of Math Appendices
| Appendix |
Type |
Class |
| Budget Constraint for n Goods |
Math/Economics |
1.2 class |
| Material on Preferences |
Math/Economics |
1.3 class |
| Steepness & Indifference Curves For Neutrals |
Math/Economics |
1.3 class |
| Derivation of MRS Equation (as ratio of marginal utilities) |
Proof |
1.3 class |
| Utility Functions and PMTs |
Math |
1.3 class |
| Graphing Indifference Curves |
Math |
1.3 class |
| Utility Functions for Perfect Substitutes |
Math |
1.3 class |
| Utility Functions for Perfect Complements |
Math |
1.3 class |
| Cobb-Douglas Functions |
Math |
1.3 class |
| Example Demand Functions |
Math |
1.6 class |
| Example Applications of Consumer Theory Models |
Applications |
1.7 class |
| Derivation of MRTS Equation (as ratio of marginal products) |
Proof |
2.2 class |
| Solving the Firm’s Problem in One Step |
Math |
2.2 class |
| The Geometry of Short-Run Production |
Math/Economics |
2.2 class |
| The Relationship Between Marginal and Average |
Math/Economics |
2.2 class |
| A Change in Relative Factor Prices |
Applications |
2.3 class |
| Improvements in Technology |
Applications |
2.3 class |
Last updated on Jul 20, 2021


Calendar QML Type
Provides a way to select dates from a calendar More...
| Import Statement: | import QtQuick.Controls 1.4 |
| Since: | Qt 5.3 |
| Inherits: |
Properties
- dayOfWeekFormat : int
- frameVisible : bool
- maximumDate : date
- minimumDate : date
- navigationBarVisible : bool
- selectedDate : date
- style : Component
- visibleMonth : int
- visibleYear : int
- weekNumbersVisible : bool
Signals
- clicked(date date)
- doubleClicked(date date)
- hovered(date date)
- pressAndHold(date date)
- pressed(date date)
- released(date date)
Methods
- void showNextMonth()
- void showNextYear()
- void showPreviousMonth()
- void showPreviousYear()
Detailed Description
Calendar allows selection of dates from a grid of days, similar to QCalendarWidget.
The dates on the calendar can be selected with the mouse, or navigated with the keyboard.
The selected date can be set through selectedDate. A minimum and maximum date can be set through minimumDate and maximumDate. The earliest minimum date that can be set is 1 January, 1 AD. The latest maximum date that can be set is 25 October, 275759 AD.
The selected date is displayed using the format in the application's default locale.
Week numbers can be displayed by setting the weekNumbersVisible property to true
.
Calendar { weekNumbersVisible: true }
You can create a custom appearance for Calendar by assigning a CalendarStyle.
Property Documentation
The format in which the days of the week (in the header) are displayed.
Locale.ShortFormat
is the default and recommended format, as Locale.NarrowFormat
may not be fully supported by each locale (see Locale String Format Types) and Locale.LongFormat
may not fit within the header cells.
This property determines the visibility of the frame surrounding the calendar.
The default value is true
.
maximumDate : date |
The latest date that this calendar will accept.
By default, this property is set to the latest maximum date (25 October, 275759 AD).
minimumDate : date |
The earliest date that this calendar will accept.
By default, this property is set to the earliest minimum date (1 January, 1 AD).
This property determines the visibility of the navigation bar.
The default value is true
.
This QML property was introduced in QtQuick.Controls 1.3.
selectedDate : date |
The date that has been selected by the user.
This property is subject to the following validation:
- If selectedDate is outside the range of minimumDate and maximumDate, it will be clamped to be within that range.
- selectedDate will not be changed if
undefined
or some other invalid value is assigned. - If there are hours, minutes, seconds or milliseconds set, they will be removed.
The default value is the current date, which is equivalent to:
new Date()
style : Component |
The style Component for this control.
See also Qt Quick Controls Styles QML Types.
This property determines which month in visibleYear is shown on the calendar.
The month is from 0
to 11
to be consistent with the JavaScript Date object.
See also visibleYear.
This property determines which year is shown on the calendar.
See also visibleMonth.
This property determines the visibility of week numbers.
The default value is false
.
Signal Documentation
clicked(date date) |
Emitted when the mouse is clicked on a valid date in the calendar.
date is the date that the mouse was clicked on.
The corresponding handler is onClicked
.
doubleClicked(date date) |
Emitted when the mouse is double-clicked on a valid date in the calendar.
date is the date that the mouse was double-clicked on.
The corresponding handler is onDoubleClicked
.
hovered(date date) |
Emitted when the mouse hovers over a valid date in the calendar.
date is the date that was hovered over.
The corresponding handler is onHovered
.
pressAndHold(date date) |
Emitted when the mouse is pressed and held on a valid date in the calendar.
date is the date that the mouse was pressed on.
The corresponding handler is onPressAndHold
.
This QML signal was introduced in QtQuick.Controls 1.3.
pressed(date date) |
Emitted when the mouse is pressed on a valid date in the calendar.
This is also emitted when dragging the mouse to another date while it is pressed.
date is the date that the mouse was pressed on.
The corresponding handler is onPressed
.
released(date date) |
Emitted when the mouse is released over a valid date in the calendar.
date is the date that the mouse was released over.
The corresponding handler is onReleased
.
Method Documentation
Sets visibleMonth to the next month.
Sets visibleYear to the next year.
Sets visibleMonth to the previous month.
Sets visibleYear to the previous year.


Missing Required Controller
$compile
Controller '{0}', required by directive '{1}', can't be found!
This error occurs when HTML compiler
tries to process a directive that specifies the
in a require
optiondirective definition
,
but the required directive controller is not present on the current DOM element (or its ancestor element, if ^
was specified).
To resolve this error ensure that there is no typo in the required controller name and that the required directive controller is present on the current element.
If the required controller is expected to be on a ancestor element, make ensure that you prefix the controller name in the require
definition with ^
.
If the required controller is optionally requested, use ?
or ^?
to specify that.
Example of a directive that requires ngModel
controller:
myApp.directive('myDirective', function() {
return {
require: 'ngModel',
...
}
}
This directive can then be used as:
<input ng-model="some.path" my-directive>
Example of a directive that optionally requires a form
controller from an ancestor:
myApp.directive('myDirective', function() {
return {
require: '^?form',
...
}
}
This directive can then be used as:
<form name="myForm">

</form>


"DATE "the fruit of a species of palm (q.v.), the Phoenix dactilifera. This was a common tree in Palestine (Joel 1:12; Nehemiah 8:15). Palm branches were carried by the Jews on festive occasions, and especially at the feast of Tabernacles (Leviticus 23:40; Nehemiah 8:15).
"DATE "the fruit of a species of palm (q.v.), the Phoenix dactilifera. This was a common tree in Palestine (Joel 1:12; Nehemiah 8:15). Palm branches were carried by the Jews on festive occasions, and especially at the feast of Tabernacles (Leviticus 23:40; Nehemiah 8:15).


WITNESS LIST Transportation Committee March 30, 1999-3:00P HB 539 For: Nelson, Bill (Self and Mayor, City of Lumberton) Reynolds, Norman (Self and City Administrator, City of Lumberton) On: Heald, Wes (Department of Transportation) Registering, but not testifying: On: Patton, Dan (Texas Parks and Wildlife) HB 676 For: Floeck, Clifford (Self) Spencer, Todd (Owner-Operator Independent Drivers Association) Registering, but not testifying: For: Baxter, Harry (Self) Kaderli, C. Ray (Self) Kaderli, Clifton (Self) Reid, Allen (Self) Reid, Deborah (Self) Simpson, Phillip (Self) Warden, R.T. (Self) Against: Presnal, James (State Farm Insurance Companies) On: Lopez, Carlos (Texas Department of Transportation) HB 1075 On: Lopez, Carlos (Texas Department of Transportation) Mills, Lester (Department of Public Safety) HB 1147 Registering, but not testifying: On: Mills, Lester (Department of Public Safety) HB 1708 For: Rash, Jeannete (Texas Towing and Storage Association) Registering, but not testifying: On: Beck, Robert (Texas Department of Transportation) Chamberlain, Monty (Texas Department of Transportation) HB 2004 For: Caraway, Luanne (Self and Tax Assessor-Collector's Association) Wells Spears, Nelda (Self and Tax Assessor-Collector's Association) On: Hunt, Darrel (Texas Department of Transportation) HB 2043 Against: Nelson, Roger (Self) Registering, but not testifying: For: Sheehan, Thomas (DFW International Airport) HB 2400 Registering, but not testifying: On: Chamberlain, Monty (Texas Department of Transportation) HB 2461 Registering, but not testifying: On: Hunt, Darrel (Texas Department of Transportation) HB 2537 For: Pearson, Chris (Self) On: Bray, Brett (Texas Motor Vehicle Board) HB 2539 For: Mitchamore, Greg (Self) Registering, but not testifying: On: Bray, Brett (Texas Motor Vehicle Board) HB 3014 On: Hunt, Darrel (Texas Department of Transportation) Registering, but not testifying: On: Smith, Ricky (Major, Department of Public Safety) HB 3092 For: Fondren, Gene (Texas Automobile Dealers Association) Against: Dunne, Francis (General Motors Corp.) MacDonald, Jill (Alliance of Automobile Manufacturers, Association of International Automobile Manufacturers) Roberts, Ross (Ford Motor Company) Roche, Jr., Kenneth (Gulf States Toyota, Inc.) Ryan, Charlie (Gulf States Toyota, Inc.) Thornton, Don (Self) Registering, but not testifying: Against: Hackney, Clint (Houston-Galveston Area Council) On: Bray, Brett (Texas Motor Vehicle Board) HB 3328 On: Lopez, Carlos (Texas Department of Transportation) HB 3402 For: Hooper, Sr., Jerry (Aircraft Owner and Pilots Association) Hyde, Ronald (Self) Looke, Bill (Brazoria County Airport) On: Fulton, Dave (Texas Department of Transportation) Registering, but not testifying: For: Phillips, Darrell (Self) HB 3588 For: Cox, Kevin (Dallas/Fort Worth International Airport) HB 3673 For: Parnell, James (Dallas Police Associations) Registering, but not testifying: On: Hunt, Darrel (Texas Department of Transportation) HB 3684 For: Alejandro, Leo (Self) Martin, Jack (Martin Valley Ranches Inc.) Taylor, Des (Self and Texas Recreational Vehicle Association) Villareal, Jr., Domingo (Self) HB 3717 For: Fondren, Gene (Texas Automobile Dealers Associations) Against: Ryan, Charlie (Gulf States Toyota) Registering, but not testifying: On: Bray, Brett (Texas Motor Vehicle Board)


With New Dreams, New Hopes And A Desire To Achieve New Horizons,
We Are Stepping Into A New Beginning Of Wedded Life.
Because You Have Shared In Our Lives
Through Kinship, Friendship And Love,
You Are Cordially Invited To Grace
The Beginning Of Our New Life Together.
Please join us from December 22-24 in Delhi & on December 28, 2016 in Mumbai as we celebrate our wedding.
hfehie hflfdnl j iehf hfhafbg ooosisjaj sdlfknfln nfeoifh hjlsgngjdn
jdkejdl efnvnd,mv dvaa aaaaaa kfnjjjj jjjjjjj jjjjjjn sdnvdvn


You may know him. It's a YouTube user and he upload funny BF3 videos.
Here's his channel:
http://www.youtube.com/user/birgirpall
IMHO his best best:
http://www.youtube.com/watch?v=N5IIGXbwN-o
All his "Operation":
http://www.youtube.com/playlist?list=PLA0B17928287D22B9
Latest video:
http://www.youtube.com/watch?v=0ugFEy1pOCQ


Online medical service system
objective || patients-side
- appointment online
- discuss with video chat
- prescribed by email
- Blood bank info
- secure
- nearest pharamcy info
- hometown doctor,hospital,ambulance
- medicine home-delivery (dhaka)
- foreigner doctor (later)
objective || doctor-side
- freelance type job
- visit on video chat
- set desired visit price
- paid (90%) by bank or mastercard
- secure
objective || hospital-side
- promote services by ads
- join as team (doctor panel)
- publish schedule and doctor lists
project || outcome
- patients can discuss from anywhere
- time safe
- doctor can earn as freelnace
- secure
- all in one (medical service)
Motivation
“Project for Bangladesh”
Challenges
- Security concern
- Identify doctor
- Payment gateway
- Management
- Funding
Future Plan
- Launch Daktaribd on market
- Beta testing this january
- Fundraising
Project for Bangladesh
10% for Bangladesh project


script binding engine -- bind Lua, Google V8 Javascript and Python to C++
Binding Lua, Google V8 Javascript and Python engine to C++
Binding Lua, Google V8 Javascript and Python engine to C++
Overviewback top
The binding engine uses reflection meta data as the source.
What can the binding engine doback top
- Bind C++ class to Lua, Google V8 Javascript and Python. Then Lua, Google V8 Javascript and Python can create instance, invoke class member function, get/set class field or property, and more.
- Bind C++ enum type to Lua, Google V8 Javascript and Python. Then Lua, Google V8 Javascript and Python can access the enum value by name.
- Bind C++ functions (global or member) to Lua and V8.
- Bind C++ values to Lua, V8 and Python variable.
- Bind C++ operators to Lua (Lua only). The overloaded operators in C++ are bound to Lua together with the class.
- Invoke Lua, Google V8 Javascript and Python functions from C++.
- Get and set Lua, Google V8 Javascript and Python value from C++.
- Transfer binary data between C++ and script.
- Pass script function and object to C++.
Get startback top
To binding Lua, include the header,
cpgf/scriptbind/gluabind.h
For V8, include the head,
cpgf/scriptbind/gv8bind.h
For Python, include the head,
cpgf/scriptbind/gpythonbind.h
First, we need a GScriptObject or IScriptObject (the interface version) object.
Lua version:
GScriptObject * createLuaScriptObject(IMetaService * service, lua_State * L, const GScriptConfig & config);
IScriptObject * createLuaScriptInterface(IMetaService * service, lua_State * L, const GScriptConfig & config);
The first parameter is a IMetaService. You can call createDefaultMetaService() or createMetaService() to create the service.
The second parameter is the Lua state.
The third one is a config. Just call GScriptConfig() to construct default one.
V8 version:
GScriptObject * createV8ScriptObject(IMetaService * service, v8::Local<v8::Object> object, const GScriptConfig & config);
IScriptObject * createV8ScriptInterface(IMetaService * service, v8::Local<v8::Object> object, const GScriptConfig & config);
The first parameter is a IMetaService. You can call createDefaultMetaService() or createMetaService() to create the service.
The second parameter is the V8 global object.
The third one is a config. Just call GScriptConfig() to construct default one.
Python version:
GScriptObject * createPythonScriptObject(IMetaService * service, PyObject * object, const GScriptConfig & config);
IScriptObject * createPythonScriptInterface(IMetaService * service, PyObject * object, const GScriptConfig & config);
The first parameter is a IMetaService. You can call createDefaultMetaService() or createMetaService() to create the service.
The second parameter is the Python object. You can use the object __main__ as the root object.
The third one is a config. Just call GScriptConfig() to construct default one.
This script object acts as a global scope. All meta data bound to this script object will be bound into Lua/V8 global space.
New named scope can be create by calling GScriptObject::createScriptObject(TheName).
Then all meta data bound to TheName can be accessed via TheName.
Such as TheName.MyClass, etc.
After getting the GScriptObject object, we get everything ready to bind the meta data to Lua and V8.
Script object APIback top
virtual void bindClass(const char * name, IMetaClass * metaClass) = 0;
Bind the meta class under the name.
After binding, all meta data are exposed to the script.
Thus the script can invoke the class member function, access field/property, invoke operator (Lua only), etc.
Some examples,
scriptObject->bindClass(metaClass->getName(), metaClass);
Bind metaClass under its meta name.
scriptObject->bindClass("MyClass", metaClass);
Bind metaClass under "MyClass".
In Lua, the script can always invoke the class name to construct new instance.
a = MyClass()
a is constructed with the default constructor.
b = MyClass(5)
b is constructed with the constructor that accepts an integer.
In Google V8 Javascript, the keyword "new" must be used to invoke the constructor.
a = new MyClass()
a is constructed with the default constructor.
b = new MyClass(5)
b is constructed with the constructor that accepts an integer.
virtual void bindEnum(const char * name, IMetaEnum * metaEnum) = 0;
Bind the meta enumerator to script.
Assume we have the enumerator,
enum MyEnum { x, y, z };
After binding MyEnum, in the script, we can access the value by,
a = MyEnum.x
b = MyEnum.y
virtual void bindFundamental(const char * name, const GVariant & value) = 0;
Bind the fundamental value to script.
A fundamental value is the value with primary type, such as integer, float, bool, double, etc.
virtual void bindAccessible(const char * name, void * instance, IMetaAccessible * accessible) = 0;
Bind a field or property to script. Here accessible means a field or property.
Lua binding performance warning: binding an accessible to a script object may slow down the accessing to that script object.
So if performance is important for you, don't bind accessible to global script object.
Google V8 doesn't have this impact.
virtual void bindString(const char * stringName, const char * s) = 0;
Bind a string to script.
After binding, "s" is safe to be freed in C++. The script will hold a copy of the string.
virtual void bindObject(const char * objectName, void * instance, IMetaClass * type, bool transferOwnership) = 0;
Bind an object instance to script.
"instance" is the object pointer.
"type" is the meta class for the object.
If "transferOwnership" is true, the object will be freed by the script. If it's false, the C++ code will be responsible to free the object.
irtual void bindRaw(const char * name, const GVariant & value) = 0;
Bind raw object to script.
A raw object, is either a pointer or object.
This is useful to bind object which has no meta data, aka, not reflected.
The parameter "value" must hold a pointer, or an object. It can't be fundamental or string.
The script can't access any members in the raw object.
The script can only store the raw object and pass the object back to C++.
virtual void bindMethod(const char * name, void * instance, IMetaMethod * method) = 0;
Bind a C++ function to script.
"instance" is the object instance for the function. It's NULL for global function.
"method" is the meta method.
method can be a class member function, and "instance" should point to the object. Then the method will behave as a global function in current script object.
For example, if we have an object "obj" of MyClass, and it has a method "add",
Pseudo code: bindMethod("AnotherAdd", obj, meta method of MyClass::add);
Then in script, to call the method, just write "AnotherAdd(blah, blah)", no object is required.
Note: only use this function to bind method in global scope. You don't need to bind member function for class. bindClass will do it for you.
virtual void bindMethodList(const char * name, IMetaList * methodList) = 0;
Bind a group of C++ functions to script under the "name".
Then all methods are treated as overloaded functions in the script.
Pseudo code:
methodList->add(meta method of MyClass::addLess, &myObject); // int addLess(int)
methodList->add(meta method of global addMore, NULL); // int addMore(int a, int b)
bindMethodList("add", methodList);
Then in script, "add(5)" will invoke MyClass::addLess, "add(8, 9)" will invoke addMore.
virtual IMetaClass * getClass(const char * className) = 0;
Return the meta class that's bound to script using the API bindClass;
virtual IMetaEnum * getEnum(const char * enumName) = 0;
Return the meta enum that's bound to script using the API bindEnum;
virtual GVariant getFundamental(const char * name) = 0;
Return the fundamental value that's bound to script using the API bindFundamental;
virtual std::string getString(const char * stringName) = 0;
Return the string that's bound to script using the API bindString;
virtual void * getObject(const char * objectName) = 0;
Return the object that's bound to script using the API bindObject;
To get the meta class of the object, call getType.
Note: Don't free the returned object.
virtual GVariant getRaw(const char * name) = 0;
Return a raw object.
virtual IMetaMethod * getMethod(const char * methodName) = 0;
Return the meta method that's bound to script using the API bindMethod.
This function will return NULL for the method that's bound by bindClass,
virtual IMetaList * getMethodList(const char * methodName) = 0;
Return the meta method list that's bound to script using the API bindMethodList.
This function will return NULL for the method list that's bound by bindClass,
virtual GScriptDataType getType(const char * name, IMetaTypedItem ** outMetaTypeItem) = 0;
Get the type of a name in the script engine. The name can be any legal name that exists in the script engine.
If "outMetaTypeItem" is not NULL and if the name has a meta type, the meta type will be stored into outMetaTypeItem.
In this case, you must call releaseReference on outMetaTypeItem to release it after finishing using it.
Here is the list of the data type,
sdtUnknown -- can't determine the type
sdtNull -- NULL. It's nil in Lua and null or undefined in Javascript.
sdtFundamental -- fundamental type. Can be boolean, integer, float, etc.
sdtString -- string. Can be obtained as C string.
sdtClass -- C++ class that bound to the script engine.
sdtObject -- C++ object.
sdtMethod -- C++ function.
sdtMethodList -- a group of C++ functions.
sdtEnum -- C++ enumerator.
sdtScriptObject -- A script object. Meta data can be added to it. C++ object is NOT script object.
sdtScriptMethod -- Function in the script.
virtual GScriptObject * createScriptObject(const char * name) = 0;
Create a new script object int current script object.
The new script object can be used to bind meta data.
If "name" is a C++ object, the function will fail and return NULL.
Note: you should free the returned object.
virtual GScriptObject * gainScriptObject(const char * name) = 0;
Get existing script object int current script object.
The script object can be used to bind meta data.
If "name" is a C++ object, the function will fail and return NULL.
Note: you should free the returned object.
virtual GVariant invoke(const char * name, const GVariant * params, size_t paramCount) = 0;
Invoke a function named "name" in the script.
This can be any function, such as a function written in script, or a C++ function bound to the script.
The parameters are passed as a pointer to a GVariant.
virtual GVariant invokeIndirectly(const char * name, GVariant const * const * params, size_t paramCount) = 0;
Same as "invoke", but the parameters are passed as a pointer to a GVariant pointer.
virtual void assignValue(const char * fromName, const char * toName) = 0;
Assign a script value named "fromName" to another script value named "toName".
virtual bool valueIsNull(const char * name) = 0;
Return true if the script value is null.
Note: Any empty value, undefined value, and null value, are treated as null.
virtual void nullifyValue(const char * name) = 0;
Set the script value to null.
This is helpful to release any bound value in the script.
Utility APIback top
To easy the use, there are some utility APIs in gscriptbindutil.h
GMetaVariant invokeScriptFunction(GScriptObject * scriptObject, const char * name, GMetaVariant P1, GMetaVariant P2, ..., GMetaVariant PN);
GMetaVariant invokeScriptFunction(IScriptObject * scriptObject, const char * name, GMetaVariant P1, GMetaVariant P2, ..., GMetaVariant PN);
Invoke a script function.
Example,
GMetaVariant result = invokeScriptFunction(binding, "funcAdd", 8, 2);
IScriptObject * scriptObjectToInterface(GScriptObject * scriptObject);
Wrap GScriptObject object to IScriptObject.
Note: the returned interface will not own the scriptObject. The caller should delete scriptObject.
IScriptObject * scriptObjectToInterface(GScriptObject * scriptObject, bool freeObject);
If freeObject is true, the returned interface will free the script object.
void injectMetaClassToScript(IScriptObject * scriptObject, IMetaClass * metaClass, void * instance);
Inject a class to the script. It will bind all methods, enumerators, nested class, in metaClass, to scriptObject in global scope.
"instance" is the object if metaClass is not global.
The function is usually only useful to bind the whole global meta class.
So if metaClass is a top level global class, calling
injectMetaClassToScript(myScriptObject, globalClass, NULL);
will bind everything in the meta system to the script.
Passing script function and object to C++back top
The script function and object here are the function and object defined in the script, not exposed by C++.
When the script is calling a C++ function, or setting a property, a script function will be wrapped in a IScriptFunction interface, and a script object will be wrapped in a IScriptObject interface.
Then the C++ code can use the interfaces to access the script function and object.
Notes:
1, If the script interface is passed as method parameter, don't release it. The caller will release it.
2, Don't pass script interface to field. You should use property with getter and setter to set the data.
In the setter, addReference must be called on the interface to retain it. Otherwise, the interface will be released by the script.
Using binary data in script -- the interface IByteArrayback top
IByteArray is an interface that can be used by script to read and write binary data.
An IByteArray can be created in C++ as: IByteArray * ba = byteArrayToInterface(new GByteArray, true);
To use IByteArray in script, the interface must has its meta data.
There are functions to build meta data for IByteArray in include/cpgf/metadata/util/gmetadata_bytearray.h
A GVariant that holds an IByteArray has special conversion rules.
When the GVariant is converted to "IByteArray *", the result is a pointer to IByteArray.
When the GVariant is converted to any pointers other than "IByteArray *", such as converted to "void *", "int *", etc, the result is a pointer to the memory that IByteArray holds, as if IByteArray::getMemory is called.
With these rules, script can pass an IByteArray in the same way to pass a raw memory pointer.
For example, if we have a C++ function,
void setColors(void * colors, int colorCount);
"colors" points to a buffer which is an array of integer. Then in script we can code like,
myByteArray.writeInt32(0xffffff);
myByteArray.writeInt32(0x00ffff);
setColors(myByteArray, 2);
Note: current implementation of IByteArray, the class GByteArray, use native endian that depends on the CPU. So the same data written to IByteArray will be different between Intel and ARM CPU.
You can implement IByteArray on your own needs, such as adding endian independent feature, or even encryption feature.
Below list IByteArray declaration, with some comments.
The sample code in file samples/opengl/sampleopengl.cpp has some good demonstration for how to use binary data in script.
struct IByteArray : IExtendObject {
// Get the raw memory
virtual void * G_API_CC getMemory() = 0;
// Get current position. All read/write operations are performed on current position.
virtual uint32_t G_API_CC getPosition() = 0;
// Set current position.
virtual void G_API_CC setPosition(uint32_t position) = 0;
// Get the memory length. Note: when writting to the end of the memory, the memory will grow automatically.
virtual uint32_t G_API_CC getLength() = 0;
// Set the memory length. Don't need to call it unless you want to reserver property memory.
virtual void G_API_CC setLength(uint32_t length) = 0;
// Read data from current position, then current position will move to next data.
virtual int8_t G_API_CC readInt8() = 0;
virtual int16_t G_API_CC readInt16() = 0;
virtual int32_t G_API_CC readInt32() = 0;
virtual int64_t G_API_CC readInt64() = 0;
virtual uint8_t G_API_CC readUint8() = 0;
virtual uint16_t G_API_CC readUint16() = 0;
virtual uint32_t G_API_CC readUint32() = 0;
virtual uint64_t G_API_CC readUint64() = 0;
virtual float G_API_CC readFloat32() = 0;
virtual double G_API_CC readFloat64() = 0;
virtual void G_API_CC readBuffer(void * buffer, uint32_t length) = 0;
// Write data to current position, then current position will move to next data.
virtual void G_API_CC writeInt8(int8_t value) = 0;
virtual void G_API_CC writeInt16(int16_t value) = 0;
virtual void G_API_CC writeInt32(int32_t value) = 0;
virtual void G_API_CC writeInt64(int64_t value) = 0;
virtual void G_API_CC writeUint8(uint8_t value) = 0;
virtual void G_API_CC writeUint16(uint16_t value) = 0;
virtual void G_API_CC writeUint32(uint32_t value) = 0;
virtual void G_API_CC writeUint64(uint64_t value) = 0;
virtual void G_API_CC writeFloat32(float value) = 0;
virtual void G_API_CC writeFloat64(double value) = 0;
virtual void G_API_CC writeBuffer(const void * buffer, uint32_t length) = 0;
};


Source code for map.map_info.models
"""
Models and Manager for map information
======================================
>>> miki= User.objects.create_user('miki', 'miki', 'miki')
>>> layer=Layer.objects.create(name='first layer', description='This is the first layer',owner=miki)
>>> point=SimplePoint.objects.create(name='a point', description='This is the first point', layer=layer,
>>> owner=miki, point=...)
>>> points=layer.points.all()
>>> points.count()
1
>>> points[0].name
a point
>>> areas=layer.areas.all()
>>> areas.count()
0
>>> area=SimpleArea.objects.create(name='an area', description='This is the first area', layer=layer,
polygon=....)
>>> areas.count()
1
"""
from django.contrib.gis.db import models
from django.contrib.auth.models import User
[docs]class Layer(models.Model):
""" Layers model
holds information about the supported layers. each layer has a unique name
which is it's primary key. and a reference to the user who created it.
Layer has related key called points for that retrieves the points of the
layer.
class variables:
-name: layer name, string.
-owner: the user who created the layer, User.
"""
name = models.TextField(primary_key=True, verbose_name="Layer name:")
owner = models.ForeignKey(User, related_name='layers')
def __unicode__(self):
return self.name
[docs]class Point(models.Model):
"""Data holder.
Point instance holds the data and metadata of 1 report. points has an
automatic id as primary key.
Point has 2 related names:
-User with related_name='points'
-Layer with related_name='points'
class variables:
-layer: the layer of the point. determined by the type of data.And defined
by a foreign key to a layer model.
-user: the user who added the point. a foreign key to a User model.
-point: a latitude/ longitude point that represent the place of the data
on the map.
-date_added: date of adding the point to the database. Auto generated
field.
-report_date: the date in which the data where collected.
-address: text field, a human readable address.
-subject: the report subject/title (very short, describes the what the
report is all about).
-description: a short description of the data (few sentences)
-file: DEPRECATED a path to the data file on the hard disk (not in use
currently).
-view_count: counter for how many times the point was viewed.
-objects: used by geodjango. enables geographical queries.
"""
layer = models.ForeignKey(Layer, related_name='points')
user = models.ForeignKey(User, related_name='points')
point = models.PointField()
date_added = models.DateField(auto_now_add=True)
report_date = models.DateField()
address = models.TextField()
subject = models.TextField()
description = models.TextField()
file = models.FilePathField()
views_count = models.IntegerField()
objects = models.GeoManager()
#TODO add more fields and base methods
[docs]class Area(models.Model):
"""used to describe an area of authority
Currently not in use.
"""
multipolygon = models.MultiPolygonField()


SImple Network Python Library for Education (SINPLE)
SINPLE is a Python 3 library of functions to create and analyse networks, i.e. graphs, of social relations, transport links, communication channels, etc.
SINPLE is a pedagogical (i.e. simple, readable, and documented) implementation to help introduce Python, data structures and algorithms, and network/graph theory. SINPLE includes almost 50 exercises and a small real-life network. SINPLE presents network concepts through executable definitions (functions) and concrete examples (unit tests).
SINPLE handles undirected graphs with nodes represented by any hashable value, e.g. an integer, a string of the node's name, or a tuple with additional information about the node.
SINPLE's functions assume their arguments are correct, i.e. are of the right
type and satisfy any additional stated conditions. All functions
that take as arguments a graph and some edges (or nodes),
except network()
and add_edges()
,
assume that the graph contains those edges or nodes.
SINPLE is available under a permissive license from http://tiny.cc/sinple.
Functions named with adjectives or is_
noun return booleans.
Functions named with nouns return network entities or metrics.
The code passes the PEP8 style checker.
SINPLE contains many exercises, of varying type and difficulty. Some exercises are more relevant for introductory Python courses, some for data structures and algorithms courses, others for network courses.
Exercises aren't ordered by type or difficulty: they appear as soon as they can be solved, using the preceding functions. Exercises at the end of SINPLE require changes throughout the library. Exercises are grouped in bullet lists; there is no heading introducing them.
A general, implicit, exercise is to study and understand the code. Some exercises focus on explaining particular functions.
Some exercises ask to change existing functions, others to add new code. When writing a new function, think about its name and parameters, any preconditions the user needs to know about, and add the corresponding unit tests.
Please don't share exercise solutions publicly.
The mathematical basis of network science is graph theory. Graph terminology varies among authors. We follow the Wikipedia glossary of graph theory. except in using 'node' instead of 'vertex'. If a term has multiple meanings in the literature, we chose one of them.
In SINPLE, a network (also called a graph) is a set of nodes connected by a set of undirected edges. Each pair of nodes is connected by one edge or it is not connected. A node may be connected to itself.
SINPLE represents a network by a tuple (nodes, edges)
,
where nodes
is a set of hashable values (numbers, strings, tuples, etc.)
and edges
is a set of edges.
Each edge is a set of nodes {node1, node2}
,
because the edge has no direction.
Start with the empty graph, which has no nodes and hence no edges.
EMPTY = (set(), set())
Return the set of the graph's edges.
def edge_set(graph):
(nodes, edges) = graph
return edges
assert edge_set(EMPTY) == set()
Return the set of the graph's nodes.
def node_set(graph):
(nodes, edges) = graph
return nodes
assert node_set(EMPTY) == set()
Create an edge connecting the two nodes, which may be the same.
def edge(node1, node2):
return frozenset({node1, node2})
The order of nodes doesn't matter.
assert edge(1, 2) == edge(2, 1)
The function to deconstruct a previously constructed edge returns a pair
instead of a set to allow obtaining each node with the assignment
(n1, n2) = endpoints(e)
.
def endpoints(edge):
Return a pair with the edge's endpoints (the nodes it connects).
if len(edge) == 2:
return tuple(edge)
else:
return tuple(edge) + tuple(edge)
assert endpoints(edge(2, 1)) == (2, 1) or endpoints(edge(2, 1)) == (1, 2)
assert endpoints(edge(1, 1)) == (1, 1)
Create a new graph by adding the set of edges and their endpoints to graph.
def add_edges(edges, graph):
Start with the empty set. Note that {}
is the empty dictionary.
nodes = set()
for edge in edges:
Add both endpoints to the set.
nodes.update(endpoints(edge))
The new graph's nodes/edges is the union of the old and new sets.
return (node_set(graph) | nodes, edge_set(graph) | edges)
assert node_set(add_edges({edge(2, 1)}, EMPTY)) == {1, 2}
A convenience function for the common case of adding a single edge.
def add_edge(node1, node2, graph):
Create a new graph by adding to graph the nodes and an edge between them.
The two nodes can be the same.
return add_edges({edge(node1, node2)}, graph)
assert node_set(add_edge(1, 1, EMPTY)) == {1}
Create a graph with the given sets of nodes, edges, and their endpoints.
def network(edges, nodes=set()):
return add_edges(edges, (nodes, set()))
assert network(set()) == EMPTY
assert network({edge(1, 2)}) == network({edge(2, 1)}, {1, 2})
Create a new graph by removing the set of edges from graph.
Edges that don't exist in the graph are ignored.
def delete_edges(edges, graph):
return (node_set(graph), edge_set(graph) - edges)
assert delete_edges({edge(1, 2)}, EMPTY) == EMPTY
A convenience function for the common case of deleting a single edge.
def delete_edge(node1, node2, graph):
Create a new graph by removing from graph the edge between the nodes.
return delete_edges({edge(node1, node2)}, graph)
assert delete_edge(1, 2, network({edge(2, 1)})) == network(set(), {1, 2})
delete_nodes()
and delete_node()
.
Don't forget to remove the attached edges.A null graph has no edges.
N1 = network(set(), {1})
N2 = network(set(), {1, 2})
The smallest non-simple graph has a single loop.
LOOP = network({edge(1, 1)})
A complete graph Kn connects each node to all other n-1 nodes.
K2 = network({edge(1, 2)})
K3 = network({edge(1, 2), edge(1, 3), edge(2, 3)})
A cycle graph Cn has n nodes connected in a 'round-robin' fashion. Cycle graphs can be drawn as regular shapes: triangle, square, pentagon, etc.
C3 = network({edge(1, 2), edge(2, 3), edge(3, 1)})
C4 = add_edges({edge(3, 4), edge(4, 1)}, delete_edge(3, 1, C3))
C5 = add_edges({edge(4, 5), edge(5, 1)}, delete_edge(4, 1, C4))
The Petersen graph is a (counter-)example of various graph concepts.
PETERSEN = add_edges({
It is usually drawn as an inner pentagram (C5)
edge(6, 8), edge(8, 10), edge(10, 7), edge(7, 9), edge(9, 6),
connected to
edge(1, 6), edge(2, 7), edge(3, 8), edge(4, 9), edge(5, 10)},
an outer pentagon (C5).
C5)
PETERSEN
.The utility graph connects 3 houses to 3 utilities.
UTILITY = network({
edge(house, utility)
for house in [1, 2, 3] for utility in ["gas", "water", "power"]
})
In December 1970, the Arpanet (the precursor of the Internet) had 13 nodes. Source: http://som.csudh.edu/cis/lpress/history/arpamaps.
ARPANET = network({
edge("SRI", "Stanford"), edge("SRI", "UCSB"),
edge("SRI", "UCLA"), edge("SRI", "Utah"),
edge("Stanford", "UCLA"), edge("UCLA", "UCSB"), edge("UCLA", "RAND"),
edge("RAND", "SDC"), edge("SDC", "Utah"), edge("Utah", "MIT"),
edge("RAND", "BBN"), edge("MIT", "BBN"), edge("BBN", "Harvard"),
edge("Harvard", "Carnegie"), edge("Carnegie", "CASE"),
edge("CASE", "Lincoln"), edge("Lincoln", "MIT")
})
The 'kite network' by David Krackhardt illustrates different centralities. Source: http://www.orgnet.com/sna.html
KITE = network({
edge("Andre", "Beverly"), edge("Andre", "Carol"),
edge("Andre", "Diane"), edge("Andre", "Fernando"),
edge("Beverly", "Diane"), edge("Beverly", "Ed"),
edge("Carol", "Diane"), edge("Carol", "Fernando"),
edge("Diane", "Ed"), edge("Diane", "Garth"),
edge("Fernando", "Garth"), edge("Fernando", "Heather"),
edge("Garth", "Heather"), edge("Heather", "Ike"), edge("Ike", "Jane")})
Wayne Zachary obtained in the 1970s the ties between a karate club's members. Source: http://www-personal.umich.edu/~mejn/netdata/
KARATE = network({
edge(2, 1), edge(3, 1), edge(3, 2), edge(4, 1), edge(4, 2), edge(4, 3),
edge(5, 1), edge(6, 1), edge(7, 1), edge(7, 5), edge(7, 6),
edge(8, 1), edge(8, 2), edge(8, 3), edge(8, 4), edge(9, 1), edge(9, 3),
edge(10, 3), edge(11, 1), edge(11, 5), edge(11, 6), edge(12, 1),
edge(13, 1), edge(13, 4),
edge(14, 1), edge(14, 2), edge(14, 3), edge(14, 4),
edge(17, 6), edge(17, 7), edge(18, 1), edge(18, 2),
edge(20, 1), edge(20, 2), edge(22, 1), edge(22, 2),
edge(26, 24), edge(26, 25), edge(28, 3), edge(28, 24), edge(28, 25),
edge(29, 3), edge(30, 24), edge(30, 27), edge(31, 2), edge(31, 9),
edge(32, 1), edge(32, 25), edge(32, 26), edge(32, 29),
edge(33, 3), edge(33, 9), edge(33, 15), edge(33, 16), edge(33, 19),
edge(33, 21), edge(33, 23), edge(33, 24), edge(33, 30), edge(33, 31),
edge(33, 32),
edge(34, 9), edge(34, 10), edge(34, 14), edge(34, 15), edge(34, 16),
edge(34, 19), edge(34, 20), edge(34, 21), edge(34, 23), edge(34, 24),
edge(34, 27), edge(34, 28), edge(34, 29), edge(34, 30), edge(34, 31),
edge(34, 32), edge(34, 33)})
The 'Southern Women' dataset about attendance of social events by women in Natchez MS, USA, was collected in the 1930s by Davis et al. Source: Figure 1 of http://moreno.ss.uci.edu/86.pdf Note that other online datasets, e.g. igraph, use the probably erroneous Figure 2.
WOMEN = network({
edge("Evelyn", 1), edge("Evelyn", 2), edge("Evelyn", 3), edge("Evelyn", 4),
edge("Evelyn", 5), edge("Evelyn", 6), edge("Evelyn", 8), edge("Evelyn", 9),
edge("Laura", 1), edge("Laura", 2), edge("Laura", 3), edge("Laura", 5),
edge("Laura", 6), edge("Laura", 7), edge("Laura", 8),
edge("Theresa", 2), edge("Theresa", 3), edge("Theresa", 4),
edge("Theresa", 5), edge("Theresa", 6), edge("Theresa", 7),
edge("Theresa", 8), edge("Theresa", 9),
edge("Brenda", 1), edge("Brenda", 3), edge("Brenda", 4), edge("Brenda", 5),
edge("Brenda", 6), edge("Brenda", 7), edge("Brenda", 8),
edge("Charlotte", 3), edge("Charlotte", 4),
edge("Charlotte", 5), edge("Charlotte", 7),
edge("Frances", 3), edge("Frances", 5),
edge("Frances", 6), edge("Frances", 8),
edge("Eleanor", 5), edge("Eleanor", 6),
edge("Eleanor", 7), edge("Eleanor", 8),
edge("Pearl", 6), edge("Pearl", 8), edge("Pearl", 9),
edge("Ruth", 5), edge("Ruth", 7), edge("Ruth", 8), edge("Ruth", 9),
edge("Verne", 7), edge("Verne", 8), edge("Verne", 9), edge("Verne", 12),
edge("Myra", 8), edge("Myra", 9), edge("Myra", 10), edge("Myra", 12),
edge("Katherine", 8), edge("Katherine", 9), edge("Katherine", 10),
edge("Katherine", 12), edge("Katherine", 13), edge("Katherine", 14),
edge("Sylvia", 7), edge("Sylvia", 8), edge("Sylvia", 9),
edge("Sylvia", 10), edge("Sylvia", 12),
edge("Sylvia", 13), edge("Sylvia", 14),
edge("Nora", 6), edge("Nora", 7), edge("Nora", 9), edge("Nora", 10),
edge("Nora", 11), edge("Nora", 12), edge("Nora", 13), edge("Nora", 14),
edge("Helen", 7), edge("Helen", 8), edge("Helen", 10),
edge("Helen", 11), edge("Helen", 12),
edge("Dorothy", 8), edge("Dorothy", 9),
edge("Olivia", 9), edge("Olivia", 11),
edge("Flora", 9), edge("Flora", 11)
})
Return the graph's size (number of edges).
def size(graph):
return len(edge_set(graph))
assert size(EMPTY) == 0
assert size(N1) == 0
assert size(C3) == 3
assert size(PETERSEN) == 15
assert size(WOMEN) == 89
assert size(KARATE) == 78
Return the graph's order (number of nodes).
def order(graph):
return len(node_set(graph))
assert order(EMPTY) == 0
assert order(N1) == 1
assert order(C3) == order(K3)
assert order(PETERSEN) == 10
assert order(KARATE) == 34
The Southern women dataset has 14 events and 18 women.
assert order(WOMEN) == 14 + 18
Check if edge is a loop (connects a node to itself).
def is_loop(edge):
(node1, node2) = endpoints(edge)
return node1 == node2
assert is_loop(edge("A", "A"))
assert not is_loop(edge("A", "B"))
Check if the graph is simple (has no loops).
def simple(graph):
for edge in edge_set(graph):
if is_loop(edge):
return False
return True
assert simple(EMPTY)
assert simple(N1)
Any complete graph is simple.
assert simple(K3)
assert simple(PETERSEN)
assert not simple(LOOP)
Return the graph's density (ratio of actual to potential edges).
It's the size divided by the size of a complete graph of the same order. The density of the graphs with one or zero nodes is set to zero.
def density(graph):
o = order(graph)
return size(graph) / (o * (o - 1) / 2) if o > 1 else 0
assert density(EMPTY) == 0
assert density(LOOP) == 0
Every null graph has density 0.
assert density(N2) == 0
Every complete graph has density 1.
assert density(K3) == 1
A graph with loops can have density > 1.
assert density(add_edge(1, 1, K3)) > 1
Create a null graph with n nodes numbered 1 to n and no edges.
def null(n):
return network(set(), {x for x in range(1, n+1)})
assert null(0) == EMPTY
assert null(2) == N2
Create a new graph by renaming the graph's nodes as n, n+1, n+2, etc.
def renumber(graph, n=1):
number = n
map = {}
for node in node_set(graph):
map[node] = number
number = number + 1
nodeset = set(range(n, number))
edgeset = set()
for e in edge_set(graph):
(node1, node2) = endpoints(e)
edgeset.add(edge(map[node1], map[node2]))
return network(edgeset, nodeset)
assert renumber(EMPTY, 1) == EMPTY
assert renumber(N2, -1) == network(set(), {-1, 0})
assert renumber(network({edge("A", "B")})) == network({edge(1, 2)})
Return the graph's subgraph induced by the set of nodes.
The induced subgraph has the graph's edges that connect the given nodes.
def subgraph(nodes, graph):
edges = {edge(n1, n2) for n1 in nodes for n2 in nodes}
return network(edges & edge_set(graph), nodes)
assert subgraph({1}, N2) == N1
assert subgraph({1, 2, 3, 4, 5}, PETERSEN) == C5
&
denotes set intersection.delete_nodes
function using subgraph
.Import a random number generator with uniform distribution
from random import uniform
Return a simple random graph with n nodes and edge probability p.
The two numbers can't be negative, and p can't be larger than 1.
def random(n, p):
edges = set()
for node1 in range(1, n+1):
for node2 in range(node1+1, n+1):
if uniform(0, 1) < p:
edges.add(edge(node1, node2))
return add_edges(edges, null(n))
assert random(0, 1) == EMPTY
assert random(1, 1) == N1
assert random(3, 1) == K3
assert order(random(4, 0)) == 4
assert size(random(4, 0)) == 0
assert size(random(4, 1)) == 6
assert simple(random(4, 0.5))
Check if the nodes are adjacent (an edge connects them).
def adjacent(node1, node2, graph):
return edge(node1, node2) in edge_set(graph)
assert adjacent(1, 2, K2)
assert adjacent(1, 4, C4)
assert adjacent(1, 1, LOOP)
assert not adjacent(1, 1, K2)
assert not adjacent(1, 3, C4)
Check if edge and node are incident to each other (edge connects node).
def incident(edge, node):
return node in endpoints(edge)
assert incident(edge(1, 2), 1)
assert incident(edge(1, 2), 2)
assert not incident(edge(1, 2), 3)
Return the node's degree (number of incident edge tips).
def degree(node, graph):
Loops count twice, so that each edge contributes 2 to the degree sum.
degree = 0
for edge in edge_set(graph):
if incident(edge, node):
degree = degree + 1
if is_loop(edge):
degree = degree + 1
return degree
assert degree(1, N1) == 0
assert degree(1, LOOP) == 2
assert degree(1, C4) == 2
assert degree(6, PETERSEN) == 3
Return k if graph is k-regular (all nodes have degree k), otherwise -1.
def k_regular(graph):
k = -1
for node in node_set(graph):
if k == -1:
k = degree(node, graph)
elif k != degree(node, graph):
return -1
return k
assert k_regular(EMPTY) == -1
assert k_regular(N2) == 0
assert k_regular(LOOP) == 2
assert k_regular(C3) == 2
Return the graph's degree sequence (descending list of node degrees).
def degree_sequence(graph):
degrees = [degree(node, graph) for node in node_set(graph)]
degrees.sort(reverse=True)
return degrees
assert degree_sequence(EMPTY) == []
assert degree_sequence(N2) == [0, 0]
assert degree_sequence(K3) == [2, 2, 2]
assert degree_sequence(ARPANET) == [4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2]
k_regular()
and degree_sequence()
.Return a list: the n-th value is the probability that a node has degree n.
def degree_distribution(graph):
degrees = degree_sequence(graph)
if degrees:
order = len(degrees)
n-th value is number of nodes with degree n by total number of nodes
return [degrees.count(n) / order for n in range(max(degrees)+1)]
else:
return []
assert degree_distribution(EMPTY) == []
assert degree_distribution(N2) == [1]
assert degree_distribution(LOOP) == [0, 0, 1]
degree_distribution()
to make it more efficient.Return the graph's average degree (mean of all node degrees).
def mean_degree(graph):
degrees = degree_sequence(graph)
return sum(degrees) / len(degrees) if degrees else 0
assert mean_degree(EMPTY) == 0
assert mean_degree(N2) == 0
assert mean_degree(C3) == 2
mean_degree()
to make it much more efficient.
Hint: each edge contributes 2 to the total degree count.Return the set of the node's neighbours (adjacent nodes).
def neighbours(node, graph):
return {node2 for node2 in node_set(graph) if adjacent(node, node2, graph)}
assert neighbours(1, LOOP) == {1}
assert neighbours(1, PETERSEN) == {2, 5, 6}
Return the node's open neighbourhood (subgraph induced by neighbours).
def neighbourhood(node, graph):
return subgraph(neighbours(node, graph), graph)
assert neighbourhood(1, N2) == EMPTY
assert neighbourhood(3, K3) == K2
Return node's local clustering coefficient (density of neighbourhood).
def local_clustering_coefficient(node, graph):
return density(neighbourhood(node, graph))
assert local_clustering_coefficient(1, K3) == 1
assert local_clustering_coefficient(3, PETERSEN) == 0
Return the graph's clustering coefficient, a measure of transitivity.
It measures the mean probability that A and C are connected directly if they are connected through a common node.
def global_clustering_coefficient(graph):
Count the number of paths of length 2 (ABC) and those 'closed' (ABCA).
all_paths_2 = 0
closed_paths_2 = 0
for a in node_set(graph):
for b in node_set(graph) - {a}:
for c in node_set(graph) - {a, b}:
if adjacent(a, b, graph) and adjacent(b, c, graph):
all_paths_2 += 1
if adjacent(a, c, graph):
closed_paths_2 += 1
return closed_paths_2 / all_paths_2 if all_paths_2 else 0
Any cycle graph has coefficient 0.
assert global_clustering_coefficient(C5) == 0
Any complete graph has coefficient 1.
assert global_clustering_coefficient(K3) == 1
The following graph has 6 closed paths of length 2 in the K3 triangle, and 4 open paths of length 2 due to the additional edge.
assert global_clustering_coefficient(add_edge(3, 4, K3)) == 0.6
incident()
, adjacent()
, degree()
, and neighbours()
.
Which version is the most efficient?Return a list of all geodesics [node1,...,node2]
between the two nodes.
A geodesic is a shortest path.
A path is a node sequence n_1, n_2, ... with n_i adjacent to n_i+1.
Return each path as a list of nodes. Return []
if there is no path.
Return [[node1]]
if both nodes are the same.
def geodesics(node1, node2, graph):
paths = []
candidates = [[node1]]
while candidates:
path = candidates.pop(0)
if paths and len(path) > len(paths[0]):
break
last = path[-1]
if last == node2:
paths.append(path)
else:
for neighbour in neighbours(last, graph):
if neighbour not in path:
candidates.append(path + [neighbour])
return paths
assert geodesics(1, 2, N2) == []
assert geodesics(1, 1, LOOP) == [[1]]
assert geodesics(3, 1, K3) == [[3, 1]]
assert geodesics(1, 4, C5) == [[1, 5, 4]]
Paths can be listed in any order: sort them to compare with the solution.
assert sorted(geodesics(1, 3, C4)) == [[1, 2, 3], [1, 4, 3]]
Example of 2 geodesics going through same node. Taken from Newman's "Networks: an introduction", page 187.
assert sorted(geodesics(3, 5, add_edge(1, 5, C4))) \
== [[3, 2, 1, 5], [3, 4, 1, 5]]
geodesics
works.geodesic
(singular!) function that returns
the first shortest path found, or []
if there is none.Return the distance (length of shortest path) between the nodes.
The length of a path is the number of its edges. If there's no path, the distance is infinite.
def distance(node1, node2, graph):
paths = geodesics(node1, node2, graph)
return len(paths[0]) - 1 if paths else float("infinity")
assert distance(2, 4, C4) == 2
In a complete graph, the distance between different nodes is always 1.
assert distance(3, 2, K3) == 1
In a null graph, the distance between different nodes is always infinite.
assert distance(1, 2, N2) == float("infinity")
The distance between the same node is always 0.
assert distance(1, 1, N2) == 0
distance
more efficient by calling geodesic
, if you've written it.Return the graph's diameter (longest of all pairwise distances).
def diameter(graph):
if order(graph) == 0:
return float("infinity")
nodes = node_set(graph)
return max([distance(n1, n2, graph) for n1 in nodes for n2 in nodes])
assert diameter(EMPTY) == float("infinity")
assert diameter(N1) == 0
assert diameter(N2) == float("infinity")
assert diameter(K3) == 1
assert diameter(C5) == 2
diameter()
works.diameter()
more efficient.
Hint: the distance from A to B is the distance from B to A.diameter()
using eccentricity()
.Check if graph is connected (there's a path between any pair of nodes).
def connected(graph):
for node1 in node_set(graph):
for node2 in node_set(graph):
if not geodesics(node1, node2, graph):
return False
return True
assert connected(EMPTY)
assert connected(N1)
assert not connected(N2)
assert connected(C5)
connected()
more efficient.Return a list of the graph's components (maximal connected subgraphs).
def components(graph):
components = []
visited = set()
for node in node_set(graph):
component = set()
to_visit = {node}
while to_visit:
node = to_visit.pop()
if node not in visited:
visited.add(node)
component.add(node)
to_visit = to_visit | neighbours(node, graph)
if component:
components.append(subgraph(component, graph))
return components
assert components(EMPTY) == []
assert components(K3) == [K3]
assert [order(c) for c in components(N2)] == [1, 1]
assert [size(c) for c in components(N2)] == [0, 0]
components()
works. Explain its unit tests.connected()
using components()
. Which is more efficient?Return the giant component (component with majority of graph's nodes).
Return the empty graph if there is no giant component.
def giant_component(graph):
half = order(graph) / 2
for component in components(graph):
if order(component) > half:
return component
return null(0)
assert giant_component(EMPTY) == EMPTY
assert giant_component(C3) == C3
assert giant_component(N2) == EMPTY
giant_component()
to return the largest component (most nodes).Return the k-core (maximal subgraph of nodes with degree k or more).
def k_core(k, graph):
Keep removing nodes with degree < k until no longer possible
while True:
nodes = {node for node in node_set(graph) if degree(node, graph) >= k}
if nodes == node_set(graph):
return graph
graph = subgraph(nodes, graph)
Any k-core of the empty graph is empty.
assert k_core(-1, EMPTY) == EMPTY
The 0-core of any graph is itself.
assert k_core(0, C5) == C5
If k is larger than the maximum degree, the k-core is empty.
assert k_core(3, C5) == EMPTY
If the graph is k-regular, its k-core is the whole graph.
assert k_core(k_regular(K3), K3) == K3
In the early Arpanet, no node had 3 neighbours with 3 neighbours themselves.
assert k_core(3, ARPANET) == EMPTY
k_core
using the delete_node
function.These functions relate to how 'important' a node is. The higher the value, the more central the node is. A node's degree is one such metric.
Return the betweenness centrality of the node.
def betweenness(node, graph):
It captures the extent to which shortest paths go through the node.
centrality = 0
for node1 in node_set(graph):
for node2 in node_set(graph):
paths = geodesics(node1, node2, graph)
if paths:
on_paths = sum(1 for path in paths if node in path)
centrality = centrality + on_paths / len(paths)
return centrality
In K3, a node A is on all 9 paths except on B-B, C-C, B-C and C-B.
assert betweenness(1, K3) == 5
In a null graph, any node is only on the path with itself.
assert betweenness(1, N2) == 1
In C5, a node is on the 4+4 paths that start and end at the node, on the 1 path to itself, and on the 2 paths between its neighbours.
assert betweenness(1, C5) == 11
Utah is more central to connecting East and West coasts than CASE.
assert betweenness("Utah", ARPANET) > betweenness("CASE", ARPANET)
Return the node's closeness centrality.
def closeness(node, graph):
It indicates how close the node is to all other nodes.
Use equation 7.30 from page 184 of Newman's book: average of inverse distance to all other nodes. This handles infinite distances between unconnected nodes.
other = node_set(graph) - {node}
return sum(1 / distance(node, n, graph) for n in other)/(order(graph) - 1)
Any isolated node, e.g. in a null graph, has closeness 0.
assert closeness(1, N2) == 0
All nodes in a complete graph have closeness 1.
assert closeness(1, K3) == 1
In C5, each node is at distances 1,1,2,2 from the other four.
assert closeness(1, C5) == (1+1+.5+.5) / 4
Return the subgraph induced by all nodes up to distance d of the ego node.
def ego_graph(ego, d, graph):
nodes = {n for n in node_set(graph) if distance(ego, n, graph) <= d}
return subgraph(nodes, graph)
If the distance is set to the diameter, the ego graph is the whole graph.
assert ego_graph(5, diameter(PETERSEN), PETERSEN) == PETERSEN
For any simple graph, an ego graph with distance zero is just the ego node.
assert ego_graph(5, 0, PETERSEN) == renumber(N1, 5)
In a complete graph, any ego graph with distance > 0 is the whole graph.
assert ego_graph(1, 1, K3) == K3
These functions help read and write graphs in GML (Graph Modelling Language) format. For more details, see the GML specification.
Return a string representing the graph in GML format.
def to_gml(graph):
The nodes of the graph must be represented by integers.
Concatenating many strings is slow; join a list of strings instead.
lines = ["graph [", " directed 0"] # in GML, 0 means false
for node in node_set(graph):
lines.append(" node [id {}]".format(node))
for edge in edge_set(graph):
(node1, node2) = endpoints(edge)
lines.append(" edge [source {} target {}]".format(node1, node2))
lines.append("]")
Join the lines, separated by newlines.
return "\n".join(lines)
assert to_gml(EMPTY) == """\
graph [
directed 0
]"""
assert to_gml(LOOP) == """\
graph [
directed 0
node [id 1]
edge [source 1 target 1]
]"""
assert to_gml(N2) == """\
graph [
directed 0
node [id 1]
node [id 2]
]"""
Return the list of graphs read from text
, a string in GML format.
This function assumes that the input follows the GML specification, provides unique integer ids even for isolated nodes, and defines one or more graphs. This function ignores anything other than node ids and edge endpoints. This means directed graphs are read as undirected graphs, node labels and edge weights are discarded, etc. If an edge endpoint (integer) is an unknown node id, the node is created.
def from_gml(text):
Define the grammar with pyparsing.
Don't use from pyparsing import *
as it adds many constants
to the generated documentation.
from pyparsing import (
srange, oneOf, Forward, Optional, Suppress, Word, ZeroOrMore,
dblQuotedString, pythonStyleComment
)
digit = srange("[0-9]")
sign = Optional(oneOf("+ -"))
mantissa = Optional("E" + sign + digit)
Word(x)
is a sequence of one or more characters from the set x.
digits = Word(digit)
integer = sign + digits
real = sign + Optional(digits) + "." + Optional(digits) + mantissa
For simplicity, use pyparsing's string with double-quotes, hoping that it is a generalisation of GML's definition of a string.
string = dblQuotedString
A GML file is a list of key-value pairs, where a value may be a list. To handle this recursive definition, we delay what a pair is.
pair = Forward()
list = ZeroOrMore(pair)
A file may have comments, which are as in Python. Ignore them.
list.ignore(pythonStyleComment)
Word(x, y)
is 1 character from x followed by 0 or more from y.
key = Word(srange("[a-zA-Z]"), srange("[a-zA-Z0-9]"))
Suppress(x)
matches x but doesn't put it in the list of parsed tokens.
listValue = Suppress("[") + list + Suppress("]")
value = real | integer | string | listValue
The mandatory key-value pairs for graphs are as follows.
graph = Suppress("graph") + listValue
node = Suppress("node") + listValue
anEdge = "edge" + listValue # to avoid conflict with edge() function
id = Suppress("id") + integer
source = Suppress("source") + integer
target = Suppress("target") + integer
First try to parse graph-specific key-value pairs; otherwise ignore pair.
pair <<= graph | node | anEdge | id | source | target | Suppress(key+value)
The above suppressions lead to the GML string
'graph [ node [id 1 label "ego"] edge [source 1 target 1 weight 0.5] ]'
being parsed into the list of tokens
["1", "edge", "1", "1"]
,
which is converted by the following functions into a graph.
def to_int(text, position, tokens):
Convert parsed integer tokens to integers, e.g. ["1"]
to 1
.
return int(tokens[0])
def to_edge(text, position, tokens):
Assuming the above conversion was done,
convert ["edge", a, b]
to an edge incident to a and b.
return edge(tokens[1], tokens[2])
def to_graph(text, position, tokens):
tokens
is now a list of integers and edges, in any order.
nodes = set()
edges = set()
for token in tokens:
If the token is an integer, it's a node id.
if isinstance(token, int):
nodes.add(token)
else:
edges.add(token)
return network(edges, nodes)
Do the conversions as soon as the respective tokens are parsed.
integer.setParseAction(to_int)
anEdge.setParseAction(to_edge)
graph.setParseAction(to_graph)
Parse the text with the main grammar rule. Return the result as a list, not as a pyparsing object.
return list.parseString(text).asList()
Check that converting to GML and back returns the original graph.
assert [EMPTY] == from_gml(to_gml(EMPTY))
assert [N1] == from_gml(to_gml(N1))
assert [LOOP] == from_gml(to_gml(LOOP))
assert [K3] == from_gml(to_gml(K3))
assert [EMPTY, LOOP] == from_gml('''
graph [directed 1] # an empty graph that is (strangely enough) directed
graph [ node [id 1 label "ego"] edge [source 1 target 1 weight 0.5] ]
''')
These exercises require using or changing large parts of the library.
Write a program that imports SINPLE and reports various properties of the Arpanet network, e.g. the most highly connected nodes.
Write a program that imports SINPLE, reads a network from a GML file, e.g. provided by Mark Newman, and analyses it.
For example, download the Karate Club graph and check that it has two highly connected members, the student founder and the instructor, who are not friends of each other, and that most members are not friends of both. This conflict led to the split into two clubs.
Write a program that imports SINPLE, creates several random graphs
with fixed n
and increasing p
, and reports their properties.
Check if the mean degree is the theoretical expected value p*(n-1)
.
Check if a giant component emerges when p > 1/n
.
Check if the network becomes connected when p > math.log(n) / n
.
Functions like degree(node, graph)
assume that node
is in graph
.
What happens if it isn't?
Decide whether to return a sensible value or to raise an exception.
If the former, add unit tests.
Extend SINPLE to support weighted edges,
i.e. edges with an associated number called the edge's weight.
An unweighted network can be seen
as a weighted network where each edge has the default weight 1.
Hints: Add a default parameter to edge()
.
Add a function to return the weight of an edge.
Modify geodesics()
to return the paths with the smallest total weight.
Extend SINPLE to store node and edge data, like node and edge labels,
edge weight, etc. Change the GML functions to read and write such data.
One possibility is to represent each node by a pair (id, data)
and each edge by a pair (endpoints, data)
,
where data
is a dictionary with a key-value pair for each datum.
Another option is to put all data in a single dictionary,
indexed by nodes and edges, of dictionaries, i.e. nodes and edges
remain as now and the graph becomes a triple (nodes, edges, data)
.
Make SINPLE work with Python 2.7.
Rewrite SINPLE using classes.


Thank you for purchasing INSPINIA admin theme. If you have any questions about the template, please feel free to contact us via email<EMAIL_ADDRESS>Documentation created: 10/05/2015This documentation is focused on Meteor version. It assumes a minimum knowledge of Meteor framework. It describe mainly files and structure in project. Please note that this documentation is dedicated to the main element of the template. With each version, we will try to develop it. But if you have any questions going beyond what is described here don't hesitate to write to us on support email. We would love to help.
To run Meteor Inspinia you will need Meteor package installed. Please go to Meteor website to install package for your system: https://www.meteor.com/install
Before you run Inspinia please be sure that you can create and run sample Meteor app: https://www.meteor.com/try Please be sure that you don't have any error while runing sample Meteor app.
If everything work well please go to Meteor_Full_Version (Inspinia Meteor folder) and run meteor command
meteor
Next open your web browser and go to.
http://localhost:3000
And after that you will see the app running. If you have any problem on this stage feel free to write to us on support@webapplayers and we will try to help.
File pack containing INSPINIA Meteor template consists:
Meteor_Full_Version/
├── .meteor/
├── client/
├──── config/
├──── plugins/
├──── startup/
├──── stylesheets/
├──── views/
├── public/
├── server/
├── README.md
The main layout is a mainLayout.html file under client->views->layouts->main.html. Main layout is set in client->config->router.js as a layoutTemplate. So all views (templates in Meteor) are use this main layout.
<template name="mainLayout">
  {{> navigation }}
  {{> topNavbar }}  {{> yield}}  {{> footer }}
   {{> rightSidebar }}
  </template>
Main layout use common templates like navigation, top navbar, footer, right sidebar. All common templates you can find under client->views->common
Each page in Meteor is a template. All pages/templates you can find at client->views->pages folder.
client->views->pages/
├── appviews/
├── cssanimations/
├── dashboards/
├── forms/
├── gallery/
├── graphs/
├── gridoptions/
├── layouts/
├── mailbox/
├── miscellaneous/
├── otherpages/
├── tables/
├── uielements/
├── widgets/
Each page has also own pageHeading template - it is a heading bar with breadcrumb
It is added to view as a {{> pageHeading}}
{{> pageHeading title='Advanced form elements' category='Forms' }}
And the structure of it is:
<template name="pageHeading">

{{title}}

 Home
 {{#if category}}
 {{category}}
 {{/if}}
 {{title}}

 </template>
Meteor has own build and injection system. So you dont need to worry about adding a script. In client->plugins folder are all files for plugins. Thay are automatically added by Meteor to your app.
To manage all route we use great plugin iron-router https://github.com/iron-meteor/iron-router.
It allows you to organize the parts of your interface into a templates.
Below you can see example of configuration routes. Configuration routing are in client->config->router.js
// // Dashboards routes // Router.route('/dashboard1', function () { this.render('dashboard1'); }); Router.route('/dashboard2', function () { this.render('dashboard2'); }); Router.route('/dashboard3', function () { this.render('dashboard3'); }); Router.route('/dashboard4', function () { this.render('dashboard4'); this.layout('layout2'); }); Router.route('/dashboard4l', function () { this.render('dashboard4l'); }); ..... // Other routes
Inspinia provide few option for you layout app. There are:
Fixed sidebar is a sidebar that is sticked on screen.
To add fixed sidebar you need to add .fixed-sidebar class to body and initialize slimScroll for it.
In client->views->layouts->main.js file you can see a comment // FIXED-SIDEBAR.
To add fixed sidebar you just need to uncomment this code:
$('body').addClass('fixed-sidebar'); $('.sidebar-collapse').slimScroll({ height: '100%', railOpacity: 0.9 });
Be sure that you have slimScroll plugin in your project. (it is included in Full version as well as Seed project)
Fixed navbar is a top navbar that is sticked on screen.
In client->views->common->top-navbar.js file you can see a comment // FIXED TOP NAVBAR OPTION.
To add fixed navbar you just need to uncomment this code:
$('body').addClass('fixed-nav'); $(".navbar-static-top").removeClass('navbar-static-top').addClass('navbar-fixed-top');
Fixed navbar 2 is a top navbar that is sticked on screen and it's width is the same as the width of wrapper
In client->views->common->top-navbar.js file you can see a comment // FIXED TOP NAVBAR OPTION.
To add fixed navbar 2 you just need to uncomment this code and replace with new one:
$('body').addClass('fixed-nav').addClass('fixed-nav-basic'); $(".navbar-static-top").removeClass('navbar-static-top').addClass('navbar-fixed-top');
Fixed navbar 2 works only on primary layout
Fixed footer is a bottom footer that is sticked on screen.
In client->views->common->footer.js file you can see a comment // FIXED FOOTER.
To add fixed footer you just need to uncomment this code:
$('.footer').addClass('fixed');
Layout 2 is a top navigation with centered content layout.
For layout 2 we prepared special examples files in client->views->layouts->layout2.html
<template name="layout2">

  {{> topNavigation }}  {{> yield}}

 </template>
To use layout 2 all you need to do is to specify it with your router.js: (example from dashbard 4).
Router.route('/dashboard4', function () { this.render('dashboard4'); this.layout('layout2'); });
And you will get a Layout 2.
You have to remember that now your menu is located in client->views->common->top-navigation.html file.
Off canvas menu is a menu that not change the width of main wrapper page. It appear on top of the page.
To use off canvas menu you just need to add .canvas-menu
to body element and initialize slimScroll for it.
We add example page for offCanvas menu client->views->pages->appviews->offCanvas.html. And the js file for it:
client->views->pages->appviews->offCanvas.js.
To enable off canvas you just need to applay class and plugin in template rendered function
Template.offCanvas.rendered = function(){ // Add special class for off canvas menu layout $('body').addClass('canvas-menu'); // Initialize slimScroll for left navigation $('.sidebar-collapse').slimScroll({ height: '100%', railOpacity: 0.9 }); };
Inspinai theme has 3 diferent skins
To change skin you just have to add skin class to body element.
In client->views->layouts->main.js file you can see a comment // SKIN OPTIONS.$('body').addClass('skin-1');
In LESS files skins.less you can find style for the skin. Below is a representation of css classes demand color skin.
.skin-1
- Blue Light.skin-2
- Inspinia Ultra {for support with Inspinai Ultra please contact with<EMAIL_ADDRESS>- Yellow/purple.md-skin
- Material Design Skin (In demo Inspinia Material Design version has also fixed sidebar and fixed navbar option)It is an application skeleton for a typical Meteor web app. You can use it to quickly bootstrap your Meteor webapp projects. It has all necessary resources/files to help you started new project. As your project will grow you will need to add new resources. Look at the full version to select the elements and resources you want to use.
Seed Project you can run exactly the same as Full version by command meteor
Contact as with email: support@webapplayers.com


Player One
Games
Free Online Gaming
Home
About
High Scores
Contact Us
Want to play free games?
Login
Sign Up!
Make your opinion known!
Rate Our Games
Search
Tic Tac Toe
{{board.winning_player}} Wins!
Reset / Play Again


Module: WscSdk::Enums::IdleTimeout
- Extended by:
- WscSdk::Enums
- Defined in:
- lib/wsc_sdk/enums/idle_timeout.rb
Overview
Enumerate valid idle timeouts for a Transcoder.
Constant Summary collapse
- NONE =
No idle timeout. The transcoder will run without stopping automatically
0
- ONE_MINUTE =
Timeout after 1 minute of inactivity from the source.
1
- TEN_MINUTES =
Timeout after 10 minutes of inactivity from the source.
600
- TWENTY_MINUTES =
Timeout after 20 minutes of inactivity from the source.
1200
- THIRTY_MINUTES =
Timeout after 30 minutes of inactivity from the source.
1800
- ONE_HOUR =
Timeout after 1 hour of inactivity from the source.
3600
- SIX_HOURS =
Timeout after 6 hours of inactivity from the source.
21600
- TWELVE_HOURS =
Timeout after 12 hours of inactivity from the source.
43200
- ONE_DAY =
Timeout after 1 day of inactivity from the source.
86400
- TWO_DAYS =
Timeout after 2 days of inactivity from the source.
172800
Class Method Summary collapse
-
.values ⇒ Object
Return the valid range of values for the idle timeout.
Methods included from WscSdk::Enums
Class Method Details
.values ⇒ Object
Return the valid range of values for the idle timeout.
44 45 46 |
# File 'lib/wsc_sdk/enums/idle_timeout.rb', line 44 def self.values (NONE..TWO_DAYS) end |


You can find your package in /packages/mememe
MEAN versions prior to 0.3.2 will be in /node_modules/mememe