This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# パスの一覧を取得する…結果はコスト、辺のリスト、係数のリスト | |
def getAllPath(edges, visited, f, t, r, c, e, a): | |
if f == t: | |
r.append((c,e,a)) | |
for k in neighbor[f].keys(): | |
if k not in visited: | |
getAllPath(edges, visited + [f], k, t, r, c + neighbor[f][k][2], e + [neighbor[f][k][1]], a + [neighbor[f][k][0]]) | |
# パスに対して「今そのパスが取れる最大の値」を返す | |
def getMaximalFlow(world, (c,e,a)): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heapq | |
def tepush(l, d, m, sortkey, value): | |
if not value in d: | |
generation = 1 | |
else: | |
generation = d[value] + 1 | |
d[value] = generation | |
heapq.heappush(l, (sortkey, value, generation)) | |
length = len(l) | |
if length > m: # ヒープの再構成 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 幅優先探索 | |
import copy | |
# 近傍、使用済みフラグ(世代)の定義 | |
verts = range(1,vs + 1) | |
verts.append('s') | |
verts.append('t') | |
neighbor = {} | |
used = {} | |
used['t'] = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bsort(a) # 非破壊的 | |
l = a.length | |
b = Array.new(l){0} | |
for i in 0..(l-1) do | |
b[a[i]] = a[i] | |
end | |
return b | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> gem install natto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SampledesuController < ApplicationController | |
def index | |
render :text => "Hello, world!にほんご" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(stringr) | |
library(arules) | |
library(DiagrammeR) | |
df.test <- data.frame(a=1,b=2) | |
shinyServer(function(input, output, session) { | |
output$hideScript <- renderText({ | |
query <- parseQueryString(session$clientData$url_search) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(arulesSequences) | |
# 上述の試行錯誤の名残…arulesSequencesでarulesも入る | |
# scraping.Rの続きで | |
t <- song_data_all[,c("before","after")] | |
result <- apriori(as(t,"transactions"), parameter = list(support = 0.008, confidence = 0.05)) | |
# さだまさし→0.01/0.05 | |
# 小田和正→0.005/0.05 | |
# いきものがかり→0.005/0.05 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication3 | |
{ | |
class Program |